linux - anacron的时间戳文件记录的时间为什么只到"日"而没有具体到时和分?
巴扎黑
巴扎黑 2017-04-17 13:01:17
0
1
828

以下引用鸟哥的话:

anacron 是透过该记录与目前的时间差异,了解到是否应该要进行某项任务的工作! 举例来说,如果我的主机在 2009/03/15(星期天)
18:00 关机,然后在 2009/03/16(星期一) 8:00 启动,由於我的 crontab 是在早上 04:00
左右进行各项任务,由於该时刻系统是关机的,因此时间戳记依旧为 20090315 (旧的时间), 但是目前时间已经是 20090316
(新的时间),因此 run-parts /etc/cron.daily 就会在启动过 65 分钟后开始运行了。

疑问点是:时间戳只精确到3月15日和3月16日,那linux怎么知道3月16日开机时间一定是在4:00之后?换句话说,如果在3月16日3:00就开机,那么anacron还会执行4:00的crontab任务吗?

巴扎黑
巴扎黑

reply all(1)
洪涛

Anacron can be used to execute commands periodically, with a frequency specified in days. Unlike cron(8), it does not assume that the machine is running continuously. Hence, it can be used on machines that aren't running 24 hours a day, to control daily, weekly, and monthly jobs that are usually controlled by cron.

anacron is only accurate to the day, so just record the day it was last run.

If I have a routine task at 10 o'clock on a certain day, but I turn off my phone at 9 o'clock and turn it on at 11 o'clock

Anacron can't do this. You can only say that this task runs once a day, or once a week, or once a month.

PS: If dcron is used, it will run all missed tasks once.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!