There are several issues with how anacron is installed which will cause it to not work as intended:
1. /etc/init.d/anacron init script is not a daemon. It is meant to be executed once upon boot and exit. The script runs anacron properly but incorrectly reports its status as "crashed" when it should report itself as "stopped" because it does not continue to run in the background as a daemon after it has executed.
2. The cronie-1.2-crontab file that the ebuild installs is not modified when anacron is installed as well. When anacron is installed, it should take over the process of running the cron.daily, cron.weekly and cron.monthly scripts as documented in the package crontab file which is specifically prefixing the daily, weekly and monthly commands with this: [ ! -f /etc/cron.hourly/0anacron ] -- taken from dailyjobs file in the package.
3. /etc/cron.hourly/0anacron should always be installed as executable because that script takes over the duties of running daily, weekly and monthly scripts instead of the main crontab.
+*cronie-1.4.11-r2 (30 Mar 2014)
+ 30 Mar 2014; Lars Wendler <email@example.com> +cronie-1.4.11-r2.ebuild,
+ Attempt to fix installation of anacron as suggested by Matthew Schultz in bug
Alright... I've tried to address all your suggestions. Please give cronie-1.4.11-r2 a try and report back if all your concerns are fixed.
Any further suggestions to anacron are welcome.
I think, there's room for improvement:
1) As I mentioned in (bug 503634):
In case it should only be run if the user explicitly sets it to be executable, maybe the test in /etc/crontab which is at the moment
[ ! -f /etc/cron.hourly/0anacron ]
should be set to
[ ! -x /etc/cron.hourly/0anacron ]
2) My crontab says:
[ ! -f /etc/cron.hourly/0anacron ] && rm -f /var/spool/cron/lastrun/cron.hourly
Who is executing /etc/cron.hourly/0anacron then?
+*cronie-1.4.11-r3 (18 Apr 2014)
+ 18 Apr 2014; Lars Wendler <firstname.lastname@example.org> -cronie-1.4.11-r2.ebuild,
+ +cronie-1.4.11-r3.ebuild, files/cronie-1.3-crontab:
+ Only use anachron if 0anacron is executable.
Please test and report back if that fixes all your concerns.
I'm not 100% sure how anacron is supposed to work, so you might want to double-check my suggestion.
- As fas as I understand, anacron calls scripts in cron.daily, cron.weekly and cron.monthly. It does _not_ call scripts in cron.hourly.
- Anacron itself is called by a script in cron.hourly.
Therefore the check for /etc/cron.hourly/0anacron should _not_ be in front of the cron.hourly rm call and in front of the run-crons command. I've been using cronie with anacron and those 2 changes for more than a week now and it seems to work as expected.
As it is as of sys-process/cronie-1.4.12, configuration when using anacron is wrong - no jobs under hourly, daily, weekly or monthly gets ever executed.
In cronie, anacron is only using external invocation or through cron jobs.
Working configuration for /etc/crontab, when using anacron:
01 * * * * root run-parts /etc/cron.hourly
Maybe we should consider making anacron mandatory with cronie, because it has built in job serialization and locking, and remove /usr/sbin/run-crons, which tries to do precisely same job.