我不否认之前云服务器确实被人攻击了,还中下一个木马,服务器成了肉机,对别人发起了DDOS攻击,cpu、mem满跑,也拖垮了我的服务,很庆幸的是被我解决了。不过!最近云服务器不知道是不是又被攻击了,每天凌晨2:14,tomcat服务准时关闭,查了日志还没发现任何异常,或许是我的道行不够。情急之下,只好采取定时任务措施。希望来个大神指点下!
这是我的脚本,restart_tomcat.sh:
#!/bin/sh service tomcat restart
注:shell脚本第一句必须是:#!/bin/sh。
给系统添加定时任务:
vim /etc/crondtab
添加一条定时任务:
# For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed 16 2 * * * root /home/restart_tomcat.sh
对于定时任务的书写规范,crontab示例已经解释得很清楚,就不再多说了。
编辑好之后保存并退出:
:wq
最后记得启动:
/etc/init.d/crond start
OR
service crond start
如果需要重启:
/etc/init.d/crond restart
OR
service crond restart查看状态:
/etc/init.d/crond status
OR
service crond status暂时先这样吧!
标签: linux Centos shell 定时 crond
分享:
上一篇Centos下实现service tomcat start|stop|restart,启动、停止、重启tomcat服务
下一篇emulator: ERROR: x86 emulation currently requires hardware acceleration!
崇尚极简,热爱技术,喜欢唱歌,热衷旅行,爱好电子产品的一介码农。
联系QQ:58742094
联系电话:
工作邮箱:
当你的才华还撑不起你的野心的时候,你就应该静下心来学习,永不止步!
人生之旅历途甚长,所争决不在一年半月,万不可因此着急失望,招精神之萎葸。
Copyright 2015- 芒果酷(mangocool.com) All rights reserved. 湘ICP备14019394号
免责声明:本网站部分文章转载其他媒体,意在为公众提供免费服务。如有信息侵犯了您的权益,可与本网站联系,本网站将尽快予以撤除。