Possible Duplicate:
Leave bash script running on remote terminal while not logged in?

I have a bash script that runs Gaussian, a chemical structure calculator, which spends a couple days toying with a molecule. It runs on a Linux box that I load the input files and said script on to, then I (am supposed to) run it, wait a while, hope the program didn't crash, and log back on to collect the result.

Somewhat of a *nx newbie, but I can't seem to figure out how to set the script running and disconnect, while letting it continue on.


appears to block until it's done, and if I disconnect it terminates

./jobscript &

doesn't block, I can see it running in top, so I thought it was OK, but on logging out it apparently killed the program.

How do I set the thing to run and stay running, even if I logout?


5 Answers 5


You want to use the program screen. Here is the man page for it, and here is a nice tutorial. It should do exactly what you want it to do - execute something in the background and be able to come back to it later.

  • Looks like screen is better for me while stumbling around in a new world; it's pretty obvious when I run a script (blocking) and it dies because of some syntax error or malformed input as it returns right away.
    – Nick T
    May 13, 2011 at 0:15

You can use:

nohup /path/to/script >output 2>&1 &

You could start a screen session, start your job, and the disconnect from the screen session.

Later, you can reattach to your screen session to see if your job has completed.

See also https://serverfault.com/questions/2016/on-a-linux-server-how-do-you-use-multiple-terminals-over-a-single-ssh-connection/2027#2027

  • 2
    i highly recommend using screen over nohup
    – Roy Rico
    May 12, 2011 at 1:56


nohup - run a command immune to hangups, with output to a non-tty

man nohup


With bash:

my_program &
disown -h %1

Alter the number for your actual job number (see jobs builtin too)

Not the answer you're looking for? Browse other questions tagged .