- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- checkproc
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 04:59 AM
тАО02-08-2006 04:59 AM
Thanks
Ken
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 05:10 AM
тАО02-08-2006 05:10 AM
SolutionEssentially the universal method for doing this is to send a kill -0 PID to the PID that you are interested in. You then examine ${?}; if it's zero then that is a valid process otherwise no. The fundamental problem is that there may be many instances of a given program running. Whicjh one do you really want. Checkproc suffers from that as well and HP-UX lacks a /var/run/xxx.pid file.
kill -0 ${PIDPROC} # e.g. obtained from ps -e
STAT=${?}
if [ ${STAT} -eq 0 ]
then
"Process running"
else
"No process"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 05:12 AM
тАО02-08-2006 05:12 AM
Re: checkproc
If you mean to query whether or not a process (by name) is running or not, I use something like this:
# myproc=inetd
# [ -z "`UNIX95= ps -C initd -o pid= -o comm=`" ] && mailx -s "$myproc is not running!" root < /dev/null
'myproc' is the *basename* of the process you want to query.
If by "check a process" you mean merely to see if it is alive, then, using its pid, do:
# kill -0
Substitute the
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 05:24 AM
тАО02-08-2006 05:24 AM
Re: checkproc
checkproc checks for running processes that use the specified executable.
checkproc does not use the pid to verify a process but the full path of the corresponding program which is used to identify the executable
This is really a nice thing to have when writing a shutdown script.
Thanks,
ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 05:29 AM
тАО02-08-2006 05:29 AM
Re: checkproc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 05:37 AM
тАО02-08-2006 05:37 AM
Re: checkproc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 05:41 AM
тАО02-08-2006 05:41 AM
Re: checkproc
As Clay mentions, with a little scripting...
You can easily leverage the first technique I showed by taking your the name of your executable and using 'basename' to reduce it to the code I offered.
# myproc=/usr/sbin/inetd
# myproc=`basename $myproc}`
# [ -z "`UNIX95= ps -C $myproc -o pid= -o comm=`" ] && echo "dead" || echo "running"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-08-2006 05:55 AM
тАО02-08-2006 05:55 AM
Re: checkproc
Thanks to both for your input.
Regards,
Ken