Leave bash script running on remote terminal while not logged in?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2 Looping
--
Chapters
00:00 Leave Bash Script Running On Remote Terminal While Not Logged In?
00:28 Accepted Answer Score 18
00:51 Answer 2 Score 1
01:22 Answer 3 Score 0
01:59 Thank you
--
Full question
https://superuser.com/questions/111631/l...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#bash #ssh #remotedesktop #process
#avk47
ACCEPTED ANSWER
Score 18
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.
ANSWER 2
Score 1
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!
ANSWER 3
Score 0
What happens if you forgot to add the nohup
Command at the beginning of your Command?
Let us say that you have run the following Long Command:
This is called as ls -Ral /
that is supposed to list all of the Files and all of the Folders, including the Hidden ones, with a Long Format, Recursively starting from the Root Folder. It might take a while.
Just press ctrl+Z.
How do you get it back?
The Command to get it back into the Foreground is fg
.