Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-03-2007, 09:30 AM   #1
Registered: Feb 2007
Posts: 197

Rep: Reputation: 30
would script run after logout?


If I run a script in backgrund, would it run after logout? Or do I need to provide special command? thanks in advance.
Old 12-03-2007, 09:41 AM   #2
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35

nohup my_script &
Old 12-03-2007, 09:42 AM   #3
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
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
Old 12-03-2007, 11:21 AM   #4
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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.


detach, nohup, screen, terminal

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script run as user login or logout in Vsftpd server singhpps Linux - Software 4 11-27-2010 11:06 AM
run commands when logout desktop melinda_sayang Linux - General 1 11-08-2006 09:05 PM
On gnome / x logout run "logout" ?? once here Linux - Software 1 01-09-2004 02:53 PM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM
Run commands at logout/shutdown sbaguz Linux - General 2 08-21-2003 11:55 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration