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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ps in a shell script

Status
Not open for further replies.

husamzm

IS-IT--Management
Aug 22, 2001
6
AE
Solaris 2.7 Sparc , Ksh:
I have a script that checks for a process ID by grep a string from the output of the ps , depend on the existance of the process,it performs a specific action.

PID=`/usr/bin/ps -eo pid,comm,args | grep "process string" | /usr/bin/awk '{print $1}'`

The command line that runs the application exist in a file called #runserver

The problem is that the development team always changing the command line that runs this application,so sometimes ps output will reflect a different string or you can say shifting the string so it will not appear.
My question is can we increase the limit of the process string line catched fom the ps output command,if not can I use to check the existance of the PID from checking the file "runserver" that include the command line.
Thanks for help
 
Get the developers to alter their program - when it starts up, it should store it's own PID in a (standard location & name) file - e.g. /tmp/processPID so that your script can grab the PID from there. One by one, the penguins steal my sanity. X-)

 
or you could say:

PID=$(/usr/bin/ps -eo pid,comm,args | grep $(<runserver) | /usr/bin/awk '{print $1}')

which will read the command name from the file 'runserver' for you Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
grep to the file that contain the command line worked fine
Thanks alot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top