Linux工具-crontab
参考文献
crontab
-
crond
是linux
下的一个守护进程,用于定期执行某些任务或等待某些事件被处理,类似于windows
下的计划任务,当操作系统安装完成后,会默认安装这个服务工具,并会自动启动crond
进程,crond
进程每分钟会定期检查是否有任务需要执行,如果有任务就会自动执行.如果有任务要执行,就会自动执行. /etc目录下有一个crontab
文件,它是系统任务调度的配置文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed- 星号(
*
):代表所有可能的值,例如月份字段为星号,则表示满足其他字段的约束后,每月执行该命令操作 - 逗号 (
,
):可以指定以逗号分隔的值的列表范围,例如“1,2,5,7,8,9” - 中线(
-
):可以在整数之间使用中线来指示整数范围,例如“2-6”表示“2,3,4,5,6” - 斜杠(
/
):可以使用斜杠指定时间间隔的频率,例如“0-23/2”表示每两小时一次.正斜杠也可以与星号一起使用,例如*/10,如果用在分钟字段中,则表示每十分钟一次.
- 星号(
示例
1 | #每天上午8点运行一次脚本: |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 HoleLin's Blog!