-----------crontab定时任务----------------------
检查crontab工具是否安装 crontab -
l
检查crontab服务是否启动 service crond status
在日志文件上每分钟把当前时间写入log.txt中
crontab -
e
*/
1 * * * * date >> /tmp/
log.txt
分 时 日 月 星期几[0或7表示星期天]
案例:
(1)每晚的21:30重启apache
30 21 * * *
service httpd restart
(2)每月的1,
10,22日的4:45重启apache
45 4 1,
10,
22 * *
service httpd restart
(3)每月的1到十日的4:45重启apache
45:
4 1-
10 * *
service httpd restart
(4)当分钟为奇数时重启apache
1-
59/
2 * * * *
service httpd restart
(5)晚上的11点到早上的7点之间,每隔一小时重启apache
0 23-
7/
1 * * * *
service httpd restart
(6)每天的18:00到23:00之间每隔30分钟重启apache
0,
30 18-
23 * * * *
service httpd restart
0-
59/
30 18-
23 * * * * service httpd restar
转载于:https://www.cnblogs.com/hgj123/p/4430705.html
相关资源:JAVA上百实例源码以及开源项目