I have a cron job that locks the computer using i3lock at a certain time (12:15), but sometimes I put the computer to sleep before 12:15. If I then I wake up the computer after 12:15 (usually around 13:30), the computer gets locked immediately after wake-up. Why is that?
My OS is Debian buster x86-64.
答案1
I know about anacron, but as I check its configuration, anacron is clearly not responsible for the immediately sleep after wake up. I read the manual about cron, and found out
Special considerations exist when the clock is changed by less than 3 hours, for example at the beginning and end of daylight savings time. If the time has moved forwards, those jobs which would have run in the time that was skipped will be run soon after the change. Conversely, if the time has moved backwards by less than 3 hours, those jobs that fall into the repeated time will not be re-run.
Only jobs that run at a particular time (not specified as @hourly, nor with '*' in the hour or minute specifier) are affected. Jobs which are specified with wildcards are run based on the new time immediately.
Clock changes of more than 3 hours are considered to be corrections to the clock, and the new time is used immediately.
and I checked the log of cron sudo journalctl -xu cron
, it did have entry tell me that cron is running the missed cron job after waking up
答案2
The reason is is the laptop is sleeping and the jobs run that are backed up. You should just lock it and not put it in sleep mode or follow this guide.