yo8192 / fcron

fcron is an advanced cron for Linux/Unix systems
http://fcron.free.fr
GNU General Public License v2.0
135 stars 12 forks source link

Run at reboot/resume if missed #31

Open AndyM48 opened 3 months ago

AndyM48 commented 3 months ago

I have a job: &bootrun 0 5 * * * /usr/sbin/logwatch --output mail My understanding is that this job will run at 5 minutes after midnight every day, and at reboot/resume if missed: bootrun Run an &-line at fcron's startup (or system's resume after suspend/hibernation) if it should have run during system down time In fact the job runs as expected, except that it runs a second time at reboot, so clearly I don't understand bootrun correctly.

Log:

{resumed from suspend)
Jul 24 08:14:01 acer fcron[2365]: suspend/hibernate detected: we woke up after 42108s instead of 900s. The system was suspended for 41626s.
...
Jul 24 08:14:07 acer fcron[23580]: Job '/usr/sbin/logwatch --output mail' started for user systab (pid 23582)
Jul 24 08:14:12 acer fcron[23580]: Job '/usr/sbin/logwatch --output mail' completed
(rebooted nothing logged)
Jul 24 08:19:40 acer fcron[5068]: Job '/usr/sbin/logwatch --output mail' started for user systab (pid 5070)
Jul 24 08:19:46 acer fcron[5068]: Job '/usr/sbin/logwatch --output mail' completed
AndyM48 commented 2 months ago

Perhaps bootrun man should read:

bootrun Run an &-line at fcron's startup, or system's resume after suspend/hibernation if it should have run during system down time.

?

yo8192 commented 2 months ago

I wonder if fcron had a chance to save the state when you rebooted. If it didn't, then it wouldn't know that the job was already run so it would run it (again).

Do you see a line like:

2024-08-22T17:34:31.113829+01:00 <cron.debug> fcron[84153]:  Saving systab...

right before the reboot?

If not:

AndyM48 commented 2 months ago

I wonder if fcron had a chance to save the state when you rebooted. If it didn't, then it wouldn't know that the job was already run so it would run it (again).

Right, so my settings/understanding are not wrong. I cannot remember a line like that in the log, so that may be the problem, I will need to do some checks to see.

For the record:

Thank you for your help

AndyM48 commented 2 months ago

Logically I think your assumption is correct. 'Clean' reboot did not show duplicate cron jobs. But: I cannot find any messages similar to the one you showed, anywhere. Where should I expect to find it? I looked in crond.log and also ran a grep -r as root, in the logs folder /var/log.

yo8192 commented 2 months ago

Those are DEBUG log-level messages. To see them, you need to: