- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Setting up cronjob
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
03-04-2003 05:40 PM
03-04-2003 05:40 PM
I've setup a cronjob to stop and start the webserver at a schduled time. Now I would like to setup so that if the webserver is not able to start properly, it should send an email notification to me. Will appreciate for your help on this.
The crontab entry is as excerpted below:
0 02 * * * /users/skverma/stop_web > /dev/null 2>&1
5 02 * * * /users/skverma/start_web > /dev/null 2>&1
Regards,
Sanjay
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:50 PM
03-04-2003 05:50 PM
SolutionI'd suggest adding some code to your 'start_web' script. I don't know what command you run in the script to start the web server, but if the command gives you a non-zero return code if there is a problem you could trap for it and send yourself an e-mail. Something like this:
web_start_command
RC=$?
if [[ RC -gt 0 ]];
then
echo "Problem starting web server" | mailx -s "Web server start problem" sanjay@yourmail.com
fi
If you don't get a valid return code from your command, you could check for a process and send an e-mail if that process isn't running.
Just a couple of ways to try it.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:53 PM
03-04-2003 05:53 PM
Re: Setting up cronjob
Modify your start_web script and append the following.
your_startup_web
..
..
HTTPDS=$(ps -ef|grep httpd|grep -v grep |wc -l|awk '{print $2}')
if [ $HTTPDS = 0 ]
then
echo "WEB Services did not start on $(hostname)" |mailx -s "$0 failed" yourid@yourdomain.com
The above script will work provided the daemons run as httpd. If not, replace httpd with the appropriate daemon name in the grep command.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 05:58 PM
03-04-2003 05:58 PM
Re: Setting up cronjob
Thanks for your quick response. I've only one line in the script as excerpted below:
cd /opt/psoft/weblogic/6.10/config/domain.sanjay;nohup startPIA.sh &
Now the question is, if I need to start the Weblogic for multiple domains, i.e., domain.sanjay, domain.office, domain.home etc. and I've setup the script like below, how am I going to identify the process related with each domain?? Or you can suggest the best way to do this.
cd /opt/psoft/weblogic/6.10/config/domain.sanjay;nohup startPIA.sh &
cd /opt/psoft/weblogic/6.10/config/domain.office;nohup startPIA.sh &
cd /opt/psoft/weblogic/6.10/config/domain.home;nohup startPIA.sh &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 06:04 PM
03-04-2003 06:04 PM
Re: Setting up cronjob
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 06:19 PM
03-04-2003 06:19 PM
Re: Setting up cronjob
Make this as a function like this that can take arguments.
//
check_web()
{
PROC=$1
NUM_PROCS=$(ps -ef|grep $PROC|grep -v grep |wc -l|awk '{print $2}')
if [ ${NUM_PROCS} = 0 ]
then
echo "WEB Services did not start on $(hostname)" |mailx -s "$0 failed" yourid@yourdomain.com
fo
}
cd /opt/psoft/weblogic/6.10/config/domain.sanjay;nohup startPIA.sh
check_web (proc_name_for_sanjay)
cd /opt/psoft/weblogic/6.10/config/domain.sanjay;nohup startPIA.sh &
check_web (proc_name_for_home)
etc.,
//
There are two deals here
1. You will need to have a process that is unique for each domain.
2. You will have to put a 'sleep x' after each startPIA.sh command. Or take out the &.
BTW how do your processes look like?.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 07:13 PM
03-04-2003 07:13 PM
Re: Setting up cronjob
The following is the content of the script that I've created but does not seem to be working fine. Am I making mistake somewhere?
Once this's implemented I'll go through creating the proc as indicated.
#!/bin/sh
COUNT=$(lsof | grep LISTEN | grep 50 | wc -l)
if [ $COUNT != 16 ]
then
echo "All WEB Services did not start on $(hostname)" | mailx -s "WebServer Process Failed to Restart" skverma@hotmail.com
fi
exit
When tried to execute this manually, after pressing CTRL+D after "fi" it gives mesg "EOT
Null message body; hope that's ok".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 07:23 PM
03-04-2003 07:23 PM
Re: Setting up cronjob
1. Why do you want to use lsof?. Use ps. lsof can hang or take a lot of time as it has to probe a lot. Since it was hanging (or still running), you had to press ctrl-D
2. Replace /bin/sh with /usr/bin/ksh. Depending on how your system is setup, you may be using old bourne shell.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 07:31 PM
03-04-2003 07:31 PM
Re: Setting up cronjob
Pl. find my comments below:
(a) I need to identify which ports are up so through lsof I count the rows and thus identify if all the ports are up and running properly.
(b) /bin/sh is defined in all other scripts are is working fine.
(c) If I break down the script, the exact position where it's hanging is:
#!/bin/sh
---ok
COUNT=$(lsof | grep LISTEN | grep 50 | wc -l)
---ok
if [ $COUNT != 16 ]
---ok
then
---ok
mailx -s "WbServer Process Failed to Restart" myemail@xyz.com
---Hangs (Whereas if I execute the mailx command manually on the command line it works fine)
fi
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 07:44 PM
03-04-2003 07:44 PM
Re: Setting up cronjob
Put only that mailx sentence in the script and execute and see if it works.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2003 08:28 PM
03-04-2003 08:28 PM
Re: Setting up cronjob
It all works now. The mailx was waiting for the body text and that's the reason why it was hanging up. Now, I've included echo... and then piped to mailx.
Also, I am interested in creating the function. If it's ok you can send any relevant doc. at skverma786@rediffmail.com.
Thanks once again for all your suggestions.
Cheers,
Sanjay