Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

./jobscript

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?

share|improve this question

marked as duplicate by Linker3000, Nick T, Sathya May 13 '11 at 9:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

5 Answers

up vote 6 down vote accepted

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.

share|improve this answer
    
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 '11 at 0:15
add comment

You can use:

nohup /path/to/script >output 2>&1 &
share|improve this answer
add comment

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 http://serverfault.com/questions/2016/on-a-linux-server-how-do-you-use-multiple-terminals-over-a-single-ssh-connection/2027#2027

share|improve this answer
2  
i highly recommend using screen over nohup –  Roy Rico May 12 '11 at 1:56
add comment

nohup

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

man nohup

share|improve this answer
add comment

With bash:

my_program &
disown -h %1

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

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.