- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- any idea how to check if .pid file abnormally term...
Operating System - HP-UX
1752815
Members
4531
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО06-24-2008 11:38 PM
тАО06-24-2008 11:38 PM
any idea how to check if .pid file abnormally terminated or not?
Admins,
good day.
i am writing a script to check on a given directory if .pid file present or not.
and one more issue.
any idea how to check if file terminated abnormally???
i think abnormal termination should write an exist code in some log file. but in which file and what is that error code number?
i searched in forum and find nothing. so creating this. if already a post is there, please write the link.
Thanks,
Sekar
good day.
i am writing a script to check on a given directory if .pid file present or not.
and one more issue.
any idea how to check if file terminated abnormally???
i think abnormal termination should write an exist code in some log file. but in which file and what is that error code number?
i searched in forum and find nothing. so creating this. if already a post is there, please write the link.
Thanks,
Sekar
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2008 11:50 PM
тАО06-24-2008 11:50 PM
Re: any idea how to check if .pid file abnormally terminated or not?
you can use lsof or tusc to do such thing.
a warrior never quits
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2008 01:50 AM
тАО06-25-2008 01:50 AM
Re: any idea how to check if .pid file abnormally terminated or not?
Hi Sekar,
I would consider as normal program termination (of the process which created the pid file) if the process removes its pid file before exiting.
I know that unfortunately there are quite a few daemons etc. that don't tidy up in this respect.
What you could do in such a case was to send the process a SIGNULL (provided you are permitted to signal it, either because you are root or the same user) to check if it is still alive, or if it is a stale pid file.
e.g.
# kill -0 $(cat /var/run/suspicious_proc.pid) || rm -f /var/run/suspicious_proc.pid
I would consider as normal program termination (of the process which created the pid file) if the process removes its pid file before exiting.
I know that unfortunately there are quite a few daemons etc. that don't tidy up in this respect.
What you could do in such a case was to send the process a SIGNULL (provided you are permitted to signal it, either because you are root or the same user) to check if it is still alive, or if it is a stale pid file.
e.g.
# kill -0 $(cat /var/run/suspicious_proc.pid) || rm -f /var/run/suspicious_proc.pid
Madness, thy name is system administration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2008 06:25 AM
тАО06-25-2008 06:25 AM
Re: any idea how to check if .pid file abnormally terminated or not?
To test the existence of a file:
if [ -e /somewhere/maybe.pid ]; then
echo "maybe.pid exists"
else
echo "maybe.pid does not exist"
fi
About abnormal terminations and exit codes:
In Unix, the exit code is given to the parent process of the exiting process. The parent process may be programmed to store the exit code somewhere, or to ignore it.
If a parent process dies while its child processes are still running, the child processes are adopted by process number 1 (init, the (grand)mother of all processes).
Unfortunately, init will not log the exit codes of adopted processes anywhere.
If you want to catch the exit code of a process, you must set up a script or something else to watch for it.
An example watcher script:
-----------
#!/bin/sh
LOGFILE=/somewhere/appmonitor.log
# start the process you wish to monitor
/somewhere/someprogram maybe-some-options
# at this point, the process has terminated.
# Catch the exit code.
EXITCODE=$?
if [ $EXITCODE -ne 0 ]; then
echo "Abnormal termination: code $EXITCODE" >>$LOGFILE
else
echo "Normal termination" >>$LOGFILE
fi
-------------
MK
if [ -e /somewhere/maybe.pid ]; then
echo "maybe.pid exists"
else
echo "maybe.pid does not exist"
fi
About abnormal terminations and exit codes:
In Unix, the exit code is given to the parent process of the exiting process. The parent process may be programmed to store the exit code somewhere, or to ignore it.
If a parent process dies while its child processes are still running, the child processes are adopted by process number 1 (init, the (grand)mother of all processes).
Unfortunately, init will not log the exit codes of adopted processes anywhere.
If you want to catch the exit code of a process, you must set up a script or something else to watch for it.
An example watcher script:
-----------
#!/bin/sh
LOGFILE=/somewhere/appmonitor.log
# start the process you wish to monitor
/somewhere/someprogram maybe-some-options
# at this point, the process has terminated.
# Catch the exit code.
EXITCODE=$?
if [ $EXITCODE -ne 0 ]; then
echo "Abnormal termination: code $EXITCODE" >>$LOGFILE
else
echo "Normal termination" >>$LOGFILE
fi
-------------
MK
MK
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP