- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: To start or not to start.......
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
тАО07-23-2002 11:27 PM
тАО07-23-2002 11:27 PM
Can I get some return value from a 'ps -ef' command which indicates whether the particular process is running?
John
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2002 11:30 PM
тАО07-23-2002 11:30 PM
Re: To start or not to start.......
ps -ef | grep -v grep | grep
Will return 1 if running and 0 if not.
If 0 then restart.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2002 11:33 PM
тАО07-23-2002 11:33 PM
Re: To start or not to start.......
Further to my last apart from restarting it you neen to find out why it is stopping.
If you instal "tusc" it will allow you to attach to the pid and monitor what it is doing.
Tusc can be downloaded here:-
http://hpux.connect.org.uk/
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2002 11:38 PM
тАО07-23-2002 11:38 PM
Re: To start or not to start.......
Thanks for your prompt reply. I know I'm really dumb, but how do I test for a returned 1 or 0 ?
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2002 11:40 PM
тАО07-23-2002 11:40 PM
Re: To start or not to start.......
because this takes processtime and will not react immediately for your critical proces.
Write a fork-ing script. The child-process will start your critical proces, in case the process dies, the child dies and the father proces will immediataly start a new child process. This will take about 2 milliseconds. The fork-ing process should run like a daemon and therefor sleeps and will not take as much resources...
I have such scripts, but is propriaty software which i can not distribute..
Regards,
Ceesjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2002 11:55 PM
тАО07-23-2002 11:55 PM
SolutionNot dumb - we all have to learn.
Hi Again
In a script :-
----------------------------cut here-------------------------------------
#!/bin/sh
#######################################
# Restart if not running
#######################################
# Is it running?
rs=`ps -ef | grep -v grep | grep ytest | wc -l`
if [[ $rs != 1 ]]
then
# Restart it
/path/to/program
fi
# Wait 10 mins and check again
sleep 600
# restart this program
exec /sysadmin/test
---------------------------cut here-----------------------------------------
The last line calls the test program - so basically it checks to see if program is running if OK does nothing , if not running it restarts it.
Sleeps for 600 seconds, then restarts itself.
start it with a nohum command - ie
# nohup /scrip/name &
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2002 11:59 PM
тАО07-23-2002 11:59 PM
Re: To start or not to start.......
the ytest in the ps -ef line must be replaced with your process name.
Further - the script checks to see if the ps -ef test is not equal to 1 -
Be aware the 2 is not equal to 1 and that multiple instances are not trapped.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2002 12:04 AM
тАО07-24-2002 12:04 AM
Re: To start or not to start.......
a standard idiom to test wether a process is alive, is to send its PID a "NULL" signal
e.g.
assume your proc has PID 1111
while kill -0 1111 2>/dev/null; do
# idle here
sleep 10
done
# then restart your proc
You asked how to check a proc's return code,
it's stored in the special variable $?
e.g.
if [ $? -ne 0 ]; then
echo "ouch, something went wrong" >&2
fi
You may also combine this in the condition:
if UNIX95= ps -e -o comm= | grep -q your_proc_name; then
echo is alive
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2002 12:19 AM
тАО07-24-2002 12:19 AM
Re: To start or not to start.......
Ralph, thanks for your answer(s). I'll need time to study them before I try them out.
Ceesjan, thanks for the advice, but system resources are not a problem.
John