simonwalz / screen-save

A tool to make screen sessions persistent = survive system reboot.
MIT License
26 stars 4 forks source link
gnu-screen persistent screen

screen-save

A tool to make screen sessions persistent = survive system reboot.

Save a screen session

The following command saves a screen session to the file ~/.screenrc_{SESSIONAME}. The created file is compatible with the screenrc definition.

screen-save [-t] SESSIONNAME [SAVE_FILE]
Options
Option Description
-t Use the current screen session. Only works inside a screen session.
SESSIONNAME Name or PID of the screen session to save.
SAVE_FILE (optional) Save session to file.
Using session names

Start a screen session with screen -S SESSIONNAME or rename an existing session by CTRL + A, : and session SESSIONAME

Example

create, reattach and save a session:

# create session
screen -S mysession
# reattach to session
screen -x
# save session
screen-save mysession
# load that session again
screen -c ~/.screenrc-mysession

Load a screen session

Use screen:

screen -c .screenrc_{SESSIONNAME}
Option Description
-c custom screen configuration file
.screenrc_{SESSIONNAME} Path to the configuration file

Automatically start sessions at system start

To start the saved screen sessions at system start, start an user crontab via:

crontab -e

and add the script screen-auto-start:

@reboot /full/path/to/screen-auto-start

The script screen-auto-start is part of this repository. Note : You need to enable a crontab to each user. Script works only to a specific user context.

Automatically save all my session

I save my sessions manually, but here is a script to save your sessions periodically:

To start the saved screen sessions at system start, start crontab via:

crontab -e

and add the script screen-save-all-sessions to save all my sessions every day at 3:00am:

0 3 * * * /full/path/to/screen-save-all-sessions

The script screen-save-all-sessions is part of this repository.

Remove a saved session

Just remove the saved screenrc file:

rm ~/.screenrc-{SESSIONNAME}

Installation

Alternatives:

Or do it manually:

Limitations