System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

want to restart httpd ( tomcat apache service) through cron

want to restart httpd ( tomcat apache service) through cron


Hi All,

I want to restart the httpd service for the application p2ms.

When I did through command then it is giving me below output tat is successful

testrt:/root #sh /usr/java/apache-tomcat-5.5.23/bin/sample.sh

Mon Feb 4 21:08:42 IST 2008
21:08:42 up 124 days, 12:23, 1 user, load average: 0.00, 0.00, 0.00
Using CATALINA_BASE: /usr/java/apache-tomcat-5.5.23
Using CATALINA_HOME: /usr/java/apache-tomcat-5.5.23
Using CATALINA_TMPDIR: /usr/java/apache-tomcat-5.5.23/temp
Using JRE_HOME: /usr/java/jdk1.5.0_05
Using CATALINA_BASE: /usr/java/apache-tomcat-5.5.23
Using CATALINA_HOME: /usr/java/apache-tomcat-5.5.23
Using CATALINA_TMPDIR: /usr/java/apache-tomcat-5.5.23/temp
Using JRE_HOME: /usr/java/jdk1.5.0_05

But when I am trying same script through crontab using user root and redirected the output to the file /tmp/output then I got only the output of date & uptime command as per below

testrt:/root #crontab -e
# Entry(s) in /opt/hpservices/RemoteSupport are for HP Instant Support Enterprise Edition
0 0 * * 1 /opt/hpservices/RemoteSupport/config/pruneIncidents.sh > /dev/null 2>&1
00,15,30,45 * * * * sh /tmp/cpu_mem_util.sh>>/tmp/ioutil.sh
2 22 * * * sh /tmp/flush_diag.sh
###################
1 2 * * * /etc/vsa/bin/dragnet >/dev/null 2>&1



#Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib/sa/sa1 -d 1 1
# 0 * * * * root /usr/lib/sa/sa1 -d 600 6 &
# Generate a daily summary of process accounting at 23:53
#18 06 * * * root /usr/lib/sa/sa2 -A
50 20 * * * sh /usr/java/apache-tomcat-5.5.23/bin/sample.sh >> /tmp/sample

~
and the contents of file /tmp/sample is as per below:

testrt:/tmp #more sample
Mon Feb 4 20:50:00 IST 2008
20:50:00 up 124 days, 12:04, 1 user, load average: 0.00, 0.00, 0.00

what is the cause here....please do the needful

Thanks in advance for your help



Many Thanks,
Sachin



1 REPLY
TwoProc
Honored Contributor

Re: want to restart httpd ( tomcat apache service) through cron

Cron doesn't go out and invoke your .bash_profile (or any other environment files), so it just doesn't know all about your CATALINA_HOME, etc. When it comes to environment variables, it really doesn't know much at all. So you need your cron job to a script that you write, in which you set all of these environment variables, and then invoke the commands to restart Tomcat.
We are the people our parents warned us about --Jimmy Buffett