本文根据 Devhints / Cron 翻译。代码示例及版本范围沿用原文。原文标注更新日期:2024-03-17。
格式
格式
Min Hour Day Mon Weekday
* * * * * command to be executed
┬ ┬ ┬ ┬ ┬
│ │ │ │ └─ Weekday (0=Sun .. 6=Sat)
│ │ │ └────── Month (1..12)
│ │ └─────────── Day (1..31)
│ └──────────────── Hour (0..23)
└───────────────────── Minute (0..59)
运算符
特殊字符串
示例
Crontab(定时任务)
# Adding tasks easily
echo "@reboot echo hi" | crontab
# Open in editor - optional for another user
crontab -e [-u user]
# List tasks - optional for another user
crontab -l [-u user]
# Delete crontab file - optional for another user
crontab -r [-u user]