Cron job to restart tomcat

Bukira
Contributor

Hi All,

We are having issues with our tomcat crashing weekly if not twice a week, we are having to manually restart it with

jssutil rt

I am trying to put this into a cron job so that it can be started every night, but its not working

i tried in the root crontab

0 0 jssutil rt >> /var/log/cron.log

but no joy it doesn't run

I have tested cron by putting in an echo line and a date line and both work well,

I also tried to make a shell script with the commands in and then run that as such

0 0 /Library/Scripts/RestartTomcat.sh >> /var/log/cron.log

but still no joy

Anyone any ideas?

Regards

Criss Myers
Senior IT Analyst (Mac Services)
iPhone / iPad Developer
Apple Certified Technical Coordinator v10.5
LIS Development Team
Adelphi Building AB28
University of Central Lancashire
Preston PR1 2HE
Ex 5054
01772 895054

10 REPLIES 10

bentoms
Release Candidate Programs Tester

Wasn't cron depreciated for launchd on osx?

Regards,

Ben.

dhowell
Contributor

I always use crontab -e Comman and then add the Task, Don't use it in OS X but it says it works

D. Trey Howell ACMT, ACHDS, CCA
trey.howell at austinisd.org
Desktop Engineering
twitter @aisdmacgeek

jarednichols
Honored Contributor

Cron was deprecated in 10.5 I believe. use launchd.

j
---
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

Bukira
Contributor

I've created a launched but cron should still work

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.devdaily.crontabtest</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/RestartTomcat.sh</string>
</array>
<key>Nice</key>
<integer>1</integer>
<key>StartInterval</key>
<integer>60</integer>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/restarttomcat.err</string>
<key>StandardOutPath</key>
<string>/tmp/restarttomcat.out</string>
</dict>
</plist>

and it works fine at running my script every 60 seconds

Criss Myers
Senior IT Analyst (Mac Services)
iPhone / iPad Developer
Apple Certified Technical Coordinator v10.5
LIS Development Team
Adelphi Building AB28
University of Central Lancashire
Preston PR1 2HE
Ex 5054
01772 895054

Bukira
Contributor

This did it so far

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.uclan.restarttomcat</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/RestartTomcat.sh</string>
</array>
<key>Nice</key>
<integer>1</integer>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<string>0</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/var/log/tomcatRTError.log</string>
<key>StandardOutPath</key>
<string>/var/log/tomcatRT.log</string>
</dict>
</plist>

my first launchdaemon

Cheers

Criss Myers
Senior IT Analyst (Mac Services)
iPhone / iPad Developer
Apple Certified Technical Coordinator v10.5
LIS Development Team
Adelphi Building AB28
University of Central Lancashire
Preston PR1 2HE
Ex 5054
01772 895054

golbiga
Contributor III
Contributor III

Criss,

What are the tomcat issues that you are seeing? We were having a lot of issues a month back that would require manual restarts a few times a week. We've made some changes since, and I've not had any issues.

Thanks
Allen

tlarkin
Honored Contributor

Use launchd instead, but I gotta ask, why do you have to constantly
restart TomCat?

-Tom

jarednichols
Honored Contributor

Correction, 10.4
---
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

abenedict
New Contributor II

What version of the JSS are you running? There was an issue in 8.1 that was
causing my JSS to lock up almost daily, the 8.22 update fixed the issue.

--
Alan Benedict
?
Macintosh Technician
The Integer Group
O: 515-247-2738
C: 515-770-8234
http://www.integer.com

RobertHammen
Valued Contributor II

There was a log purge/deletion bug in 8.21 which caused Tomcat to go out to lunch (had it on two servers, got JAMF Support involved/duplicated the problem and fixed it in 8.22). Recommend that the original poster look for the source of the issue of why Tomcat is crashing, updating their JSS if necessary...
On Sep 20, 2011, at 8:24 AM, Alan Benedict wrote:

--Robert