keep program running after logout in linux

1. Run the program with nohup, meaning no hang up. A program started with nohup command will keep running until it finishes even after you logged out of the remote server.
[code language=”shell”]
nohup ./a-long-running-script.sh &
[/code]

1. Use the screen tool
[code language=”shell”]
screen
./a-long-running-script.sh
[/code]
Then press Ctrl-a d, you should now safe to logout and the script will still be running until it finishes.

2. Run the script in the background and then disown it.
[code language=”shell”]
./another-time-consuming-script.sh #start the script
ctrl+z #To pause the program and get backt to the shell window.
bg #To run it in the background.
jobs #To display the current jobs running.
disown -h %[jobnumber] #To disown the job, so it will still be running even if you logged out.
[/code]

Search within Codexpedia

Custom Search

Search the entire web

Custom Search