Skip to content

Commit d8faf7f

Browse files
committed
新增若干内容+修改错别字
1 parent 0252895 commit d8faf7f

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

Services/cron.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@
44

55
> **cron** is the general name for the service that runs scheduled actions. **crond** is the name of the daemon that runs in the background and reads **crontab** files.
66
7-
简单理解:cron 是服务,crond 是收据进程, crontab 的 crond 的配置文件。
7+
简单理解:cron 是服务,crond 是守护进程, crontab 的 crond 的配置文件。
88

99
### 1.2 crontab 选项
1010

11-
+ `crontab -e` : Edit your crontab file, or create one if it doesn't already exist.
11+
+ `crontab -e` : Edit your crontab file, or create one if it doesn't already exist. # 推荐使用命令新增计划任务--语法检查
1212
+ `crontab -l` : Display your crontab file.
13-
+ `crontab -r` : Remove your crontab file.
13+
+ `crontab -r` : Remove your crontab file. # 慎用
1414
+ `crontab -u user` : Used in conjunction with other options, this option allows you to modify or view the crontab file of user. When available, only administrators can use this option.
1515

1616
### 1.3 crontab 格式
1717

1818
minute(s) hour(s) day(s) month(s) weekday(s) command(s)
1919

20-
+ minute: 0-59
21-
+ hour: 0-23
22-
+ day: 1-31
23-
+ month: 1-12
24-
+ weekday: 0-6, 周日:0, 周一:1, 以此类推
25-
+ command: 执行命令(注意要写绝对路径)
20+
```
21+
# Use the hash sign to prefix a comment
22+
# +—————- minute (0 – 59)
23+
# | +————- hour (0 – 23)
24+
# | | +———- day of month (1 – 31)
25+
# | | | +——- month (1 – 12)
26+
# | | | | +—- day of week (0 – 7) (Sunday=0 or 7)
27+
# | | | | |
28+
# * * * * * command to be executed
29+
```
2630

2731
## 二、使用举例
2832

@@ -41,6 +45,19 @@
4145

4246
0 10 * * * 5 /home/jerryzhang/update_weekly.py
4347

48+
(4) 每天 6, 12, 18 点执行一次命令
49+
50+
0 6,12,18 * * * /bin/echo hello
51+
52+
(5) 每天 13 点到 17 点执行一次命令
53+
54+
0 13-17 * * * /bin/echo hello
55+
56+
__注:__
57+
58+
* 程序执行完毕,系统会给对应用户发送邮件,显示该程序执行内容,如果不想收到,可以重定向内容 `> /dev/null 2>&1`
59+
* 如果执行语句中有 `%` 号,需要使用反斜杠 '\' 转义
60+
4461
## 三、参考资料
4562

4663
+ [维基百科: Cron](http://zh.wikipedia.org/wiki/Cron)

0 commit comments

Comments
 (0)