Bug 517753

Summary: RFE: Connect "@daily" and "@weekly" to anacron
Product: [Fedora] Fedora Reporter: Tim Landscheidt <tim>
Component: cronieAssignee: Ondřej Pohořelský <opohorel>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: mmaslano, pertusus, tmraz
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to add daily/weekly/monthly functionality to cron.
none
Trigger to run daily cron jobs (to be put in /etc/cron.daily).
none
Trigger to run weekly cron jobs (to be put in /etc/cron.daily).
none
Trigger to run monthly cron jobs (to be put in /etc/cron.daily).
none
Revised patch.
none
Generic trigger (to be put in /usr/sbin). none

Description Tim Landscheidt 2009-08-16 17:31:03 UTC
At the moment, vixie-cron provides simple aliases "@daily", "@weekly", etc. for special points in time. If the daemon is not run at those times though, the actions are not executed. For system-wide crontabs, this can be worked around with anacron.

  For users, Fedora provides fcron as a replacement with a multitude of options. Fcron on the other hand has problems with SELinux and its configuration is generally harder to comprehend.

  It would therefore be very nice to connect vixie-cron's "@daily", "@weekly", etc. to anacron's schedule if anacron is installed and enabled (and otherwise default to the fixed points in time). This way, users who just want to ensure that some program is run "every day" could achieve that in a simple and convenient way.

Comment 1 Marcela Mašláňová 2009-08-17 08:53:46 UTC
That's good proposal. Though I'm not sure how easy (fast) will be implementing this feature.

Comment 2 Tim Landscheidt 2009-12-11 01:31:34 UTC
I gave it a try and implemented a rough cut. As anacron is a prerequisite to cronie, it was easier than I thought.

  The patch adds a message receiver to cron that triggers jobs marked with @daily, @weekly or @monthly to be run. I kept the @midnight alias as meaning "midnight".

  The process is triggered by cron-{daily,weekly,monthly}.c that is put into /etc/cron.{daily,weekly,monthly}.

  To do:

1. Review messaging especially for security. My understanding is that the message queue is only accessible to root, but it would be nice if somebody could confirm that :-).
2. Package cron-{daily,weekly,monthly}.c correctly. My knowledge of automake & Co. is too shallow for that ATM.
3. Decide on a good file name for /etc/cron.{daily,weekly,monthly}/cron-{daily,weekly,monthly}. I do not consider the duplication very attractive.
4. Decide whether it is desirable to put binaries into /etc/cron.{daily,weekly,monthly} or instead have a /usr/bin/crontrigger that accepts "DAILY", "WEEKLY" and "MONTHLY" as argument and three small shell one-liners in /etc/cron.{daily,weekly,monthly} that call this program. I'm slightly inclined to the former as it is simpler.

Comment 3 Tim Landscheidt 2009-12-11 01:33:29 UTC
Created attachment 377637 [details]
Patch to add daily/weekly/monthly functionality to cron.

Comment 4 Tim Landscheidt 2009-12-11 01:37:39 UTC
Created attachment 377638 [details]
Trigger to run daily cron jobs (to be put in /etc/cron.daily).

Comment 5 Tim Landscheidt 2009-12-11 01:39:33 UTC
Created attachment 377639 [details]
Trigger to run weekly cron jobs (to be put in /etc/cron.daily).

Comment 6 Tim Landscheidt 2009-12-11 01:40:51 UTC
Created attachment 377640 [details]
Trigger to run monthly cron jobs (to be put in /etc/cron.daily).

Comment 7 Tomas Mraz 2009-12-11 08:13:48 UTC
The security of the use of the message queue is probably OK. There might be some problems with SELinux labels especially in regards to MLS though however these might be solved later.

There should be definitely only one binary to send the messages, placed in the /usr/sbin directory.

The problem is what to do if the cronie-anacron is not installed. This should be probably solved just by the cronie-noanacron so the jobs are triggered from there. However it means that even without anacron the jobs would be no longer run at the times specified in the manual page so the manual page should be adjusted appropriately.

And there should be probably a new command line option for cron which would make it to disable the message queue receiver and schedule the jobs at the current fixed times.

Comment 8 Tim Landscheidt 2009-12-11 17:13:12 UTC
(In reply to comment #7)
> [...]
> There should be definitely only one binary to send the messages, placed in the
> /usr/sbin directory.

I will post a short "crontrigger" later. I tried to include it in a patch/.spec, but patching only src/Makefile.ac didn't cut it, and I don't know which parts of autoconf/automake to run and files to compare to have a "meaningful" patch.

> The problem is what to do if the cronie-anacron is not installed. This should
> be probably solved just by the cronie-noanacron so the jobs are triggered from
> there. However it means that even without anacron the jobs would be no longer
> run at the times specified in the manual page so the manual page should be
> adjusted appropriately.

> And there should be probably a new command line option for cron which would
> make it to disable the message queue receiver and schedule the jobs at the
> current fixed times.  

As I'm still using F11, I didn't delve into that. In a revision of the original patch, I added an option "-a" that *enables* the interaction with anacron and made it the default via /etc/sysconfig/crond. If the option is not supplied or the message queue cannot be set up, it falls back to the old behaviour.

  configure.ac has to be amended to check for sys/msg.h. As per above, I don't know how to do that efficiently per .spec.

Comment 9 Tim Landscheidt 2009-12-11 17:24:14 UTC
Created attachment 377767 [details]
Revised patch.

sys/msg.h has to be included in configure.ac and dependents.

Comment 10 Tim Landscheidt 2009-12-11 17:26:33 UTC
Created attachment 377768 [details]
Generic trigger (to be put in /usr/sbin).

Comment 11 Fedora Admin XMLRPC Client 2014-09-04 12:14:57 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.