This is a simple one. For some reason, every time I use the screen command in terminal, I forget the commands.
There are probably lots of cool reasons to use screen but I use it to run a script over a longish period. The advantage of screen is I can start the script in the screen instance and detach from it. I can close my laptop and return later to my terminal, open my screen and check the progress of the script. Also, you can run multiple instances of a script as each screen has its own process.
So the basic commands I use and tend to forget are…
Create a screen with a label so you know what it’s for: screen -S 'run-long-script1'
Detach from the screen: Ctrl + a + d
Kill the screen: exit
Check what screens you have created: screen -ls
Open a screen that you have already created: screen -r 'run-long-script1'
Access the extensive screen manual: man screen
Found this guide helpful from thegeekstuff.
I relish, result in I found exactly what I used to be looking for.
You’ve ended my four day long hunt! God Bless you man. Have a nice day. Bye
here’s another hint for running in Terminal on Mac OS X. I have this in my .bashrc:
alias screen1=’screen -t kevin1 -d -R kevinone -e^Gg’
alias screen2=’screen -t kevin2 -d -R kevintwo -e^Gg’
alias screen3=’screen -t kevin3 -d -R kevinthree -e^Gg’
Thus, I can type screen1, screen2, or screen3 to either start or resume a previous session. Also, using these aliases allows you to use Ctrl-A (emacs keybindings) to go to the beginning of the line. Otherwise, Ctrl-A will kill your session. (not fun)