debian

Debian Crontab时间格式怎么写

小樊
42
2025-04-26 08:43:47
栏目: 智能运维

在Debian系统中,Crontab的时间格式遵循以下规则:

* * * * * command-to-be-executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday to Saturday; 7 is also Sunday)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

每个字段代表一个时间单位,从左到右依次为:分钟、小时、月份中的某一天、月份和星期中的某一天。你可以使用以下符号来指定时间范围:

以下是一些Crontab时间格式的示例:

# 每分钟执行一次命令
* * * * * command-to-be-executed

# 每天凌晨1点执行命令
0 1 * * * command-to-be-executed

# 每月1号凌晨1点执行命令
0 1 1 * * command-to-be-executed

# 每周日凌晨1点执行命令
0 1 * * 0 command-to-be-executed

# 每天上午10点到下午6点,每隔2小时执行一次命令
0 */2 10-18 * * command-to-be-executed

要编辑Crontab文件,请在终端中输入 crontab -e 命令。

0
看了该问题的人还看了