Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart Tomcat Service on AWS EC2 instance, on a schedule

I have an instance on Tomcat running on EC2. Based on some resourcing reasons that I don't want to get into, I'd like it to restart each evening at 11:00pm. I'm not interested in reloading or stopping the applications context as the PermGen space gets crowded until eventually the box tips over and dies.

So where on an aws linux instance do I specify service tomcat7 restart and give it a cron expression?

like image 755
Jamie McIlroy Avatar asked Oct 19 '25 03:10

Jamie McIlroy


1 Answers

To add a cronab entry for root user:

sudo crontab -e

which will open an editor. Insert the following line to restart tomcat7 at 11pm daily

0 23 * * * /sbin/service tomcat7 restart

Update: /sbin/service tomcat7 restart no longer works as of 2022.

like image 137
helloV Avatar answered Oct 21 '25 16:10

helloV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!