PuTTY or OTHER - Keep executing command even after exiting PuTTY
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: Industries in Orbit Looping
--
Chapters
00:00 Putty Or Other - Keep Executing Command Even After Exiting Putty
00:26 Accepted Answer Score 32
00:45 Answer 2 Score 5
01:26 Answer 3 Score 19
01:43 Answer 4 Score 3
01:59 Thank you
--
Full question
https://superuser.com/questions/841653/p...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #commandline #putty #process #gnuscreen
#avk47
ACCEPTED ANSWER
Score 32
Try
nohup Background_ScriptX &
nohup ensures that a process is not terminated when a terminal is closed. The & symbol pushes the process into the background.
Hope this was helpful.
ANSWER 2
Score 19
If you want to read the output at a later date, you can use screen
:
screen -d -m my_command
This gives you a detached terminal you can connect to later (screen -r
) to read the stdout/stderr output.
ANSWER 3
Score 5
Another option if nohup
command is not available is to use the disown command.
First you can view your background tasks by running jobs
in terminal. You can get the job number from there.
Now just run disown %[job number]
and the process will be detached from the current terminal and stay alive when you log out.
Side note: Make sure that you are asking the correct question. If you are running actual services as you hint in your sample you might want to look into how to create a daemon in the OS of your choice. This is to make sure that the process still runs after a reboot and make it more consistent with other services.
Hope this helps.
ANSWER 4
Score 3
Since screen
has been mentioned: there are other terminal multiplexers out there. I like tmux
very much, see e.g. this other superuser question, tmux vs screen for a comparison.