LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 11-11-2003, 09:44 AM   #1
drgowans
LQ Newbie
 
Registered: Sep 2003
Location: Salt Lake City, Utah
Distribution: Red Hat 9
Posts: 22

Rep: Reputation: 15
processes remain after I have logged out!


I am running Redhat 9, with GNOME.

I wrote a little script that runs in the background after I login. I placed it in my '.login' file, like this:

...
/genesis/get_mon_lx &
...

When I look at it with ps -ef, if will look like this:

image 5067 5013 0 08:33 pts/0 0:00:00 /bin/sh /genesis/get_mon_lx

This is the content of the program "get_mon_lx":

----------
while true
do
/genesis/snapshot_lx.py
sleep 1200
done
----------

The program is runs is a python program that runs for a few seconds, checks a couple processes, writes to a log file. It then waits for about 20 minutes, and runs again.

There are multiple users on this machine, and each login runs this program.

The problem is when a user logs out. This is what the process list looked like this morning:

image 4132 1 0 Nov 10 ? 0:00:00 /bin/sh /genesis/get_mon_lx
image 3144 1 0 Nov 10 ? 0:00:00 /bin/sh /genesis/get_mon_lx
image 5422 1 0 Nov 10 ? 0:00:00 /bin/sh /genesis/get_mon_lx
image 12332 1 0 Nov 10 ? 0:00:00 /bin/sh /genesis/get_mon_lx
image 2378 1 0 Nov 10 ? 0:00:00 /bin/sh /genesis/get_mon_lx
image 8733 4333 0 07:34 pts/0 0:00:00 /bin/sh /genesis/get_mon_lx

Everything that had been started the day before was still there! Why doesn't this process get killed on logout? What is going wrong? Any ideas? On other machines, I have had much cleaner logouts (HP-UX for example, always cleans up impeccably after a logout)

Help greatly appreciated. I can't have these left behind on every logout.

Thanks!
 
Old 11-11-2003, 10:12 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 33
One possible solution:

Code:
while [  /genesis/snapshot_lx.py ]
do
  ps -p $PPID > /dev/null
  if [ $? -eq 1 ]; then
     break;
  fi
  sleep 1200
done
exit
Do something to check for the existence of the parent process so it will exit when the parent process goes away. $PPID is the parent pid.
 
Old 11-11-2003, 12:56 PM   #3
drgowans
LQ Newbie
 
Registered: Sep 2003
Location: Salt Lake City, Utah
Distribution: Red Hat 9
Posts: 22

Original Poster
Rep: Reputation: 15
Thanks, that worked (or a variation on it)

Thanks Jim,

That was what I ended up doing, except I pulled out the shell script altogether and just had the python program loop, then check the parent, etc in the same way. That seems to be working very well.

Do you or anyone know why it doesn't get killed automatically when the user logs out? A feature or a bug?

Thanks!
 
Old 11-11-2003, 02:43 PM   #4
warath
Member
 
Registered: Oct 2001
Location: Ontario, Canada
Distribution: Redhat 9
Posts: 43

Rep: Reputation: 15
The process doesn't die because you told it NOT to. The '&' symbol sends the process to the background. I forget the command off the top of my head that will bring it to the foreground again. Once the program is sent to the 'background' it will stay there until you kill it, or it finishes, or you bring it back to the foreground.
 
Old 11-11-2003, 07:54 PM   #5
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 33
fg brings the process to the foreground.

And, he didn't
Code:
nohup processname &
which is really what you need to do to make a process relatively bulletproof.
 
Old 11-12-2003, 03:39 AM   #6
aqoliveira
Member
 
Registered: Dec 2001
Location: Portugal
Distribution: /Red Hat/Fedora/Solaris
Posts: 620

Rep: Reputation: 30
Howzit

well instead of running the process/script in the bg why not creat a crontab to execute that script every 20min....Just a alternative

chow
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to remain secure pandasuit Slackware 9 08-17-2004 03:42 PM
monitoring active processes and identifying the required processes. gajaykrishnan Programming 2 08-13-2004 01:58 AM
kde much slower to start when logged in as alan than logged in as root arubin Slackware 0 04-26-2004 04:27 PM
Will all of your configuration remain the same after compiling the new kernel ICO Slackware 3 01-12-2004 12:27 AM
mozilla works fine when logged in as a user but crashes when logged in as root jimi Linux - General 6 04-02-2003 08:34 PM


All times are GMT -5. The time now is 06:55 PM.

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