Perform regular tasks of linux

View the current scheduled task user can also specify the crontab -uroot -l View user's regular tasks.
Do not forget the middle of  sh  represents the user what is to execute the command

2, look at the time the expression of crontab

基本格式 :
*  *  *  *  *  command
分 时 日 月 周 命令

Then come a few practical examples:

1、每分钟执行一次            
*  *  *  *  * 

2、每隔一小时执行一次        
00  *  *  *  * 
or
* */1 * * *  (/表示频率)

3、每小时的15和30分各执行一次 
15,45 * * * * (,表示并列)

4、在每天上午 8- 11时中间每小时 15 ,45分各执行一次
15,45 8-11 * * * command (-表示范围)

5、每个星期一的上午8点到11点的第3和第15分钟执行
3,15 8-11 * * 1 command

6、每隔两天的上午8点到11点的第3和第15分钟执行
3,15 8-11 */2 * * command

3. Other Commands

名称 : crontab

使用权限 : 所有使用者

使用方式 :

crontab file [-u user]-用指定的文件替代目前的crontab。

crontab-[-u user]-用标准输入替代目前的crontab.

crontab-1[user]-列出用户目前的crontab.

crontab-e[user]-编辑用户目前的crontab.

crontab-d[user]-删除用户目前的crontab.

crontab-c dir- 指定crontab的目录。 

4, crond installation and configuration services

安装crontab:

yum install crontabs

服务操作说明:

/sbin/service crond start //启动服务

/sbin/service crond stop //关闭服务

/sbin/service crond restart //重启服务

/sbin/service crond reload //重新载入配置

查看crontab服务状态:

service crond status

手动启动crontab服务:

service crond start

查看crontab服务是否已设置为开机启动,执行命令:

 

Published 29 original articles · won praise 5 · Views 7996

Guess you like

Origin blog.csdn.net/qq_25194685/article/details/93591531