ll /etc | grep cron

linux定时任务_bash

放在标识目录里面的命令或者j脚本超过一天/一周/一年未执行的话会重新执行

 

vi /etc/logrotate.conf  自动切割系统日志的配置文件,基于cron运行

crontab  选项说明

-l  查看crontab文件内容,提示:l 为list缩写

-e 编辑crontab文件内容,提示:e为edit缩写

-i  删除crontab文件内容,删除前会提示确认,用的很少

-r 删除crontab文件内容,用的很少

-u user 指定用户执行任务。  

特别强调,-i,-r 参数在生产中很少使用,没什么需求必须要用-e进去编辑即可

补充,crontab -l/e 实际上就是操作/var/spool/cron/当前用户这样的文件

 

linux定时任务_配置文件_02

 

linux定时任务_配置文件_03

 

crontab -u username -e

*  表示每的意思

- 表示时间范围  00 17-19 * * * cmd 表示每天17点到19点

,表示分割时间段的意思 00 17,19 * * * cmd 表示 每天17点 19点

/n  n代表数字,表示每隔n单位时间  */10 * * * *  cmd 表示每隔n单位时间

 

命令举例

30 * * * * /bin/bash /tmp/echo.sh

###################################################

Crontab 编辑的定时任务依赖的任务

chkconfig --list crond

/etc/init.d/crond status  查看crond的状态

/etc/init.d/crond restart  重启crond任务