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


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

查看所有标签

猜你喜欢:

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

Chinese Authoritarianism in the Information Age

Chinese Authoritarianism in the Information Age

Routledge / 2018-2-13 / GBP 115.00

This book examines information and public opinion control by the authoritarian state in response to popular access to information and upgraded political communication channels among the citizens in co......一起来看看 《Chinese Authoritarianism in the Information Age》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具