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

Solution 1:

The command you are looking for is nohup.

There is also screen, which is for when you want to leave something running but come back and reattach interactively later.

nohup is simpler if a command expects no user input after launch, and screen is better if you want to be able to run the program interactively.

Solution 2:

I use nohup for this. In my case I had a python script named action.py I ran the script on a remote server with nohup python action.py & I would then close the terminal. Later when it's finished running, you can see all output from the process in nohup.out which will be created in the same directory as action.py. If the file already exists further output will be appended to it.

The only snag is not knowing when the script has run its course, so in my case I had it shoot me an email upon completion. Hope this helped someone!