Wednesday, April 9, 2014

Using command screen to run scripts on a remote UNIX server

Screen is a useful tool if you want to log on to the server and run a script, e.g overnight, log off, and take your laptop home. Without screen after losing connection with the server the script would simply stop. However running screen first on the server and then running your script allows you to detach from screen, then log off from the server, however your commands will still run on the server within the screen session you created. When home (or tomorrow at work) log in to the server, run screen and reattach session. You will have your script (possibly) finished.

> screen -S name
> run your script
 
ctrl-a d

Log out.

Next day:
> screen -r name

and the last screen comes back to your laptop!

No comments:

Post a Comment