Screen detach attach
-
Start screen:
screen ./run.sh
Detach from session and allow script to continue running:
**Keystroke sequence** Ctl+a then Ctl +d
Re-atatch
screen -r
View active screen sessions
screen -ls
Useful hack: At times screen will grant you issues to deal with, and not permit re attachment to the session. Or even to start a screen session. Run the following filth to circumvent said issue, either before starting screen session if needed, or before re attaching if required. Exactly as below, not the script you wish to run!
script /dev/null
If your always having issues with screen, you can set the /dev/null systemwide or in just one profile.
Add the following to the users /.bashrc file to always sent stdout to /dev/null , or nowhere
function screen() { /usr/bin/script -q -c "/usr/bin/screen ${*}" /dev/null }
Or:
Run everything in one line:
sudo su - rick -c "script -c bash /dev/null:"`
Or:
sudo -u rick script -q -c 'screen -dr myscreen' /dev/null