Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Killing a background process

Status
Not open for further replies.

kathi

Programmer
Jun 17, 2002
9
GB
I have a script running some code as a background process via nohup. I need to be able to run a script which will kill that process. I've tried to get the pid and kill it but am having trouble with that. There has to be a simple command for non-unix people to use to stop the service - i.e. I can't rely on them doing a kill -9 ! Does anyone have any simple suggestions that might help ?

My start up script is

#!/usr/bin/ksh

nohup /home/runtime/is/scripts/TransferService.sh > /home/runtime/is/log/TransferService.log &


and the entry for it if I do a ps - "pid, args" is:

16734 ksh /home/runtime/is/scripts/TransferService.sh

I'm running on AIX.

Thanks

Kathi
 
From the man page:
<snip>
When the command is invoked, nohup arranges for the SIGHUP signal to be ignored by the process.
</snip>
<snip>
The nohup utility does not arrange to make processes immune to a SIGTERM (terminate) signal, so unless they arrange to be immune to SIGTERM or the shell makes them immune to SIGTERM, they will receive it.
</snip>
 
The problem I'm having is really in identifying and sending the signal and am having problems with the man pages on this box (unfortunately I don't really have control over it)
 
Here's a thought: if your process has a name (ps -aux on most Unix/Linux systems) that it will ALWAYS have, then run a script using the ps command piped through grep, use the cut command to pull the PID of the process, and assign that to a variable, and then use kill on that PID.
<variable> = ps -aux | grep <Process name> | cut -c<point where the PID is in the column>
kill -9 $variable.
Hope this helps.
 
Thanks for the help - I bodged it with a file that holds the pid and retrieves it when you run the stop script, but I may investigate some of these.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top