在我的/etc/crontab
文件中,我有:
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
Run Code Online (Sandbox Code Playgroud)
我知道这在实践中做了什么,但我不了解命令行。
男人“测试”根本没有帮助:
test - check file types and compare values
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激
sr_*_*sr_ 15
来自 FreeBSD 的man test
:[1]
-x file True if file exists and is executable. True indicates only
that the execute flag is on. If file is a directory, true
indicates that file can be searched.
Run Code Online (Sandbox Code Playgroud)
因此,cronjobs 测试是否已anacron
安装 [2](即,在预期位置有一个名为 anacron 的可执行文件),如果没有,则运行某些内容- 即相应/etc/cron.*
文件夹中的脚本。
(2) Anacron 是一个 cron 替代品,专为不总是运行的计算机而设计,即,如果有一个工作要每周运行,它将每周运行,相对于计算机的正常运行时间,这意味着它不会每次都运行,比如说,星期五,但每 24*7 小时正常运行一次。 (编辑我都弄错了,请参阅评论)