Using screen for linux background processing

Perfect for long running batch jobs on a remote server over unreliable connections or if you want to bring your laptop home (instead of keeping that terminal running).

Log in and run
screen -t title_of_your_choice

Do the same thing again if you want to create another window.

All the following screen commands are preceeded by Ctrl-a (i.e. first press ctrl-a then the shortcut below)

  • 0-9 – switch to window by id
  • Ctrl-n – next window
  • Ctrl-a – previous window
  • K – kill window

The next day, log in as usual and attach to the screen session using

screen -x

Check the man page for screen for other options and shortcuts.

2 Comments

  1. xer says:

    hello
    nice how to
    just a question:
    how can i make a log of a background process using screen?
    i have tryied as follow:

    screen -A -m -d -S prog01 executable > server.log

    server.log is created, but with 0 rows…
    how can i fill a file with all output?
    it’s a “how to logging” ;-)
    thanx in advance

  2. xer says:

    well… i found an answer, mybe can help:
    from screen’s man:
    -L tells screen to turn on automatic output logging for the windows.

    and it works nicesly!!!
    regards

Leave a Reply