SOLVED: Cron @reboot won't work on Debian Linux


To add:

On the laptop that was installed clean from MX18 but did execute reboot I got
ps -A |grep -i cron
1051 ? 00:00:00 cron
So no anacron
But suddenly your script works, where it wouldnt on the other 3 where anacron was running together with cron. It shows anacron present.

$] ./deleteme
● ├─anacron.service
● ├─cron.service
● │ ├─anacron.timer
● ├─anacron.service
● ├─cron.service
● │ ├─anacron.timer
● ├─anacron.service
● ├─cron.service
● │ ├─anacron.timer
● ├─anacron.service
● ├─cron.service
● │ ├─anacron.timer

$]chkconfig --list |grep -i cron
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
cron 0:off 1:off 2:on 3:on 4:on 5:on 6:off

But, what is different is that anacron is not actively running allthough runlevels are set.
$]ps -A |grep -i cron
1051 ? 00:00:00 cron

So the question remains, why did anacron appear as a running daemon together with cron on three of the other computers but not on the laptop from the same install disk. Clearly hardware triggered.!

Removed anacron completely and all still works well.




To summarize for anyone having the same problem with Debian and possibly other distros
Check if both cron and anacron runs.

If both runs as below, I found the @reboot in the crontabfile will not execute.
ps-A |grep -i cron
1049 ? 00:00:00 anacron
1052 ? 00:00:00 cron

Only cron should run.

Also check runlevels with

chkconfig --list |grep -i cron
sysv-rc-conf --list |grep -i cron

There must be no mention of anacron

To get rid of anacron will mean you will loose gnome scheduler or whatever it is called. I never had use for it and I have a hunch that it is scheduler that installs anacron without regard for cron and breaks it.

To get rid of anacron
dmesg --purge anacron

then reboot and do the steps again until only cron runs as daemon.

I found that this solved both my /etc/resolv.conf and @reboot not working.



Glad it worked out for you.



Update, this cron anacron mess seems to be the work of systemd. Systemd in my opinion is most irresponsible. Not a sysadmins friend.