debian

Debian Crontab任务调度频率怎么设置

小樊
38
2025-12-05 05:06: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)

每个字段可以使用以下符号:

以下是一些示例:

  1. 每分钟执行一次命令:
* * * * * command-to-be-executed
  1. 每天凌晨1点执行命令:
0 1 * * * command-to-be-executed
  1. 每月1号凌晨1点执行命令:
0 1 1 * * command-to-be-executed
  1. 每周日凌晨1点执行命令:
0 1 * * 0 command-to-be-executed

要编辑当前用户的crontab文件,请在终端中运行以下命令:

crontab -e

要查看当前用户的crontab文件,请运行:

crontab -l

要删除当前用户的crontab文件,请运行:

crontab -r

请注意,crontab任务调度是基于系统时间的,因此请确保系统时间设置正确。

0
看了该问题的人还看了