Crontab命令格式与范例

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

内容简介:一些范例:上面的例子表示每晚的 21:30 重启 apache。上面的例子表示每月 1、10、22 日的 4 : 45 重启 apache。

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


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

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

Nginx Essentials

Nginx Essentials

Valery Kholodkov / Packt Publishing / 2015-7-1 / USD 34.99

About This Book Learn how to set up, configure, and operate an Nginx installation for day-to-day useExplore the vast features of Nginx to manage it like a pro, and use them successfully to run your......一起来看看 《Nginx Essentials》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

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

正则表达式在线测试