- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to run a process....
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
Forums
Discussions
Discussions
Discussions
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
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
08-27-2006 11:35 PM
08-27-2006 11:35 PM
One of my process goes to stop, i dont know why.
and this effect to our production.
I can check this process using this command:
# ps -ef | grep -i java*
root 3842 3820 0 06:24:21 pts/3 0:00 grep -i java
jsusr01 24904 24898 0 01:14:19 ? 0:23 /opt/java1.4/bin/IA64N/java -cp .:/apps/LoyAn/k2_test/JetQueryWebListener/latest/config:/apps/LoyAn/k2_test/JetQueryWebListener
and if it not there, then i need to start this process using:
#nohup ./runRequestListener.sh 2> /apps/LoyAn/share/JetQuery/requestListener.err 1>/dev/null&
so I want to write this script which will monitor whether this process is running or not?
if not, this script will start this process and email me for the notification.
I am able to get the emails from this server using mailx command.
Please suggest
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2006 11:43 PM
08-27-2006 11:43 PM
Re: script to run a process....
There are many ways to do this. One way is to cron the following:
#!/usr/bin/sh
# cd /runRequestListener.sh_dir
[ -z "$(UNIX95= ps -C java -o pid= -o comm=)" ] && mailx -m -s "java is not running" root && nohup ./runRequestListener.sh 2>> /apps/LoyAn/share/JetQuery/requestListener.err 1>> /dev/null &
exit 0
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2006 05:24 PM
08-28-2006 05:24 PM
Re: script to run a process....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2006 05:37 PM
08-28-2006 05:37 PM
Re: script to run a process....
#!/usr/bin/ksh
proc_pid=$(UNIX95= ps -C"process_name" -o pid|grep -v PID)
kill -0 ${proc_pid} || "code_to_start_process"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2006 06:56 PM
08-28-2006 06:56 PM
Re: script to run a process....
can you please tell me what will 1st line do and what will 2nd line do?
why i need to kill the process,
i need to start this process if it is not running
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2006 07:46 PM
08-28-2006 07:46 PM
Solutionproc_pid=$(UNIX95= ps -C"process_name" -o pid|grep -v PID)
kill -0 ${proc_pid} || "code_to_start_process"
first line:
used to get the PID of the "process_name".
second line:
kill -0 will "access to PID".
>> SIGNULL (0), the null signal, invokes error checking but no signal is
actually sent. This can be used to test the validity or existence of
pid.
if that is okay, then ""code_to_start_process" in that place, code to start the process should go. that is this part:
nohup ./runRequestListener.sh 2> /apps/LoyAn/share/JetQuery/requestListener.err 1>/dev/null&
so, in the second line ur not killing the process. just checking that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2006 08:20 PM
08-28-2006 08:20 PM
Re: script to run a process....
you can use:
#/usr/bin/ksh
NUM_PROC=$(ps -fu jsusr01|grep -c [j]ava)
if [[ $NUM_PROC = 0 ]]
then
nohup ./runRequestListener.sh 2> /apps/LoyAn/share/JetQuery/requestListener.err 1>/dev/null &
fi
#eof
please note that I use -u option to be sure that the java process is for teh rigth user.
HTH,
Art