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!

Get PID of process 4

Status
Not open for further replies.

MoreFeo

Technical User
Nov 29, 2002
547
ES
Hi, we've got an application module that needs to be restarted every morning (it's a workaround until we get a fixpack).

We've done a script that looks for its PID (by doing a ps -ef | grep $module | grep -v grep), kills it and then restarts it.

The problem is that now we're installing more modules, with similar names, so we're having troubles to identify exactly the PID of the module we want.

I'd like to know if it's possible to get the PID when the script starts the module. This way I could save the PID in a file, so the next time we wouldn't need to make the ps -ef, we would just read the PID from the file.
Is there a way to know the PID when we run the command?

This is the way we start the application module in the script (given to us by the vendor):
Code:
nohup /path/to/exec args 1>/dev/null 2&1 &


What I'd like to do is to get the PID when the script runs this command, is it possible?

Thanks
 
The 'jobs' command will return the info.
Assuming that the script only starts one process then
Code:
jobs -p > /path/to/pid/file
should do waht you want but I haven't tested this!

Ceci n'est pas une signature
Columb Healy
 
Another way:
Code:
nohup /path/to/exec args 1>/dev/null 2&1 &
echo $! > /path/to/PIDfile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Are you paying this 'vendor'? Don't think I would be 'till the 'fixpack' appears.

I want to be good, is that not enough?
 
We're having so much problems with them that they should pay us. It looks like they're testing their app with us.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top