crond命令
NAME
crond - daemon to execute scheduled commands
[root@moban ~]# vim /etc/logrotate.conf #系统自带的一些轮训日志,了解即可
[root@moban logrotate.d]# pwd
/etc/logrotate.d
crontab -l list 查看
crontab -e edit 编辑
vim /var/spool/cron/root #定时任务文件位置
基本格式 :
* * * * * command
分 时 日 月 周 命令
00 00 * * * #每天0晨
*/5 * * * * #每5分钟执行1次
30 21 * * * #表示每晚的21:30
0 */1 * * * #每一小时
45 4 1,10,22 * * #表示每月1、10、22日的4:45
0 23 * * 6 #表示每星期六的11 : 00
30 */6 * * * #没隔6小时的30分
#
-连续的 00 17-19 * * *
,列表 00 17,19 * * *
定时任务日志:
[root@moban logrotate.d]# cat /var/log/cron
定时任务: 一定要注意环境变量
需要在脚本里定义环境变量
图解: