Crontab命令格式与范例

栏目: 服务器 · 发布时间: 8年前

内容简介: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 的目录

$crontab -l 列出用户目前的 crontab

crontab 文件的基本格式 :

*    *     *     *     *     command
分   时    日    月     周    命令

第 1 列表示分钟 1~59 每分钟用*或者 */1 表示

第 2 列表示小时 1~23(0 表示 0 点)

第 3 列表示日期 1~31

第 4 列表示月份 1~12

第 5 列标识号星期 0~6(0 表示星期天)

第 6 列要运行的命令

一些范例:

30 21 * * * /usr/local/etc/rc.d/lighttpd restart

上面的例子表示每晚的 21:30 重启 apache。

45 4 1,10,22 * * /usr/local/etc/rc.d/lighttpd restart

上面的例子表示每月 1、10、22 日的 4 : 45 重启 apache。

10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart

上面的例子表示每周六、周日的 1 : 10 重启 apache。

0,30 18-23 * * * /usr/local/etc/rc.d/lighttpd restart

上面的例子表示在每天 18 : 00 至 23 : 00 之间每隔 30 分钟重启 apache。

0 23 * * 6 /usr/local/etc/rc.d/lighttpd restart

上面的例子表示每星期六的 11 : 00 pm 重启 apache。

* */1 * * * /usr/local/etc/rc.d/lighttpd restart

每一小时重启 apache

* 23-7/1 * * * /usr/local/etc/rc.d/lighttpd restart

晚上 11 点到早上 7 点之间,每隔一小时重启 apache

0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpd restart

每月的 4 号与每周一到周三的 11 点重启 apache

0 4 1 jan * /usr/local/etc/rc.d/lighttpd restart

一月一号的 4 点重启 apache


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Art of Computer Programming, Volume 3

The Art of Computer Programming, Volume 3

Donald E. Knuth / Addison-Wesley Professional / 1998-05-04 / USD 74.99

Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 3》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试