abe*_*ger 3 cron best-practices
我目前面临着一个包含十几个不同应用程序任务的 cron 文件——有些只有一个,有些有很多。我试图找出一种组织和记录这些过程的好方法。是否有任何我可以效仿的惯例,或者我是否一直在编造一些东西?
#minute hour mday month wday who command
## Acme Anvil Application
# clear logs every 5 minutes
*/5 * * * * root /path/to/clear_logs
# monthly maintenance
30 5 1 * * root /path/to/acme/maintenance
## Fabricam
# adjust timing
*/30 0-5 * * * fab /path/to/bin/fab_time
## Etc...
Run Code Online (Sandbox Code Playgroud)
如果您的系统支持 /etc/cron.d,您还可以尝试将 cron 作业分解为单个文件,并按应用程序分组。
root@linuxbox:/etc/cron.d# ls
sa-update sysstat vnstat
Run Code Online (Sandbox Code Playgroud)
请注意,/etc/cron.d 中 cron 作业的格式略有不同,因为您可以将运行命令的用户放在时间字段和命令本身之间,例如,
root@linuxbox:/etc/cron.d# cat sa-update
### OPTIONAL: Spamassassin Rules Updates ###
#
# http://wiki.apache.org/spamassassin/RuleUpdates
# Highly recommended that you read the documentation before using this.
# ENABLE UPDATES AT YOUR OWN RISK.
#
# /var/log/sa-update.log contains a history log of sa-update runs
10 4 * * * root /usr/share/spamassassin/sa-update.cron 2>&1 | tee -a /var/log/sa-update.log
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
949 次 |
最近记录: |