LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   would script run after logout? (https://www.linuxquestions.org/questions/linux-newbie-8/would-script-run-after-logout-604140/)

mokku 12-03-2007 09:30 AM

would script run after logout?
 
Hi,

If I run a script in backgrund, would it run after logout? Or do I need to provide special command? thanks in advance.

cmnorton 12-03-2007 09:41 AM

nohup
 
nohup my_script &

rjlee 12-03-2007 09:42 AM

Any program will be sent a HUP (hangup) signal when you logout.
Most programs, including scripts, will stop running if they get a HUP signal (unless they have been specifically coded to do otherwise).

You can stop a process from being killed by starting it with the nohup command. Just type nohup before the command to run.

This will rediect the standard ouput and error information to a file called nohup.out in the current working directory, and the program will be unaffected by logging out.

Hope that helps,

—Robert J Lee

matthewg42 12-03-2007 11:21 AM

An alternative is to use GNU screen. Again, you need to start this before you run the script. It allows you to "detach" your terminal session from the terminal window, and re-attach it at a later date. This is very handy for programs which are interactive, like an IRC client - you can run screen, start you IRC client, detach it from the terminal, log out, log in from another location and re-attach the screen session to your new terminal.


All times are GMT -5. The time now is 07:57 PM.