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.

nohup ./a-long-running-script.sh &

1. Use the screen tool

screen
./a-long-running-script.sh

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.

./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.

Search within Codexpedia

Custom Search

Search the entire web

Custom Search