killing a process when a user logout on FC3

Bob Chiodini rchiodin at bellsouth.net
Tue Dec 27 12:29:57 UTC 2005


On Tue, 2005-12-27 at 14:08 +0530, Ankush Grover wrote:
> hey friends,
> 
> I wanted to kill a process when the user logout.When the user logs in
> one can get the process id through this 
> 
> ps -ef | grep  process > /etc/spli.txt
> 
> But how do I kill the process when the user logout(.bash_logout) well
> there are  8 fields in /etc/spli.txt and the 2nd field is the pid
> which is needed by the kill command to end the process.
> 
> How do I extract the 2nd field from the file(/etc/spli.txt), I know
> awk or with sed one can do it but I don't know these scripting tools.
> 
> Can anyone help me in solving this issue ?
> 
> I am using FC3.
> 
> Thanks & Regards
> 
> Ankush Grover 

Ankush,

You could use cut -b 10-15 to get the pid from the output of ps -ef.
Alternately, you could use pidof.  Ala pidof pidof to get the pid of
pidof.

Bob...




More information about the fedora-list mailing list