按照计划,在AWS EC2实例上重新启动Tomcat服务

时间:2022-12-04 07:57:53

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.

我有一个在EC2上运行的Tomcat实例。基于一些我不想进入的资源原因,我希望每天晚上11点重新开始。我对重新加载或停止应用程序上下文不感兴趣,因为PermGen空间会变得很拥挤,直到最后一个方框提示结束并死亡。

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

那么,在aws linux实例上,我在哪里指定服务tomcat7重启并给它一个cron表达式呢?

1 个解决方案

#1


2  

To add a cronab entry for root user:

为root用户添加cronab条目:

sudo crontab -e

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

它将打开一个编辑器。插入以下行以在每天晚上11点重新启动tomcat7

0 23 * * * /sbin/service tomcat7 restart

#1


2  

To add a cronab entry for root user:

为root用户添加cronab条目:

sudo crontab -e

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

它将打开一个编辑器。插入以下行以在每天晚上11点重新启动tomcat7

0 23 * * * /sbin/service tomcat7 restart