TL/DR: In order for Cron to pick up that there is a new file in /etc/cron.d/* that needs to be loaded into cron, the timestamp on the file needs to be "recent". 'touch'ing a file in /etc/cron.d/ will force cron to reload the crontab.
Long story:
I've recently begun retrofitting my existing system management bash scripts into RPM packages. To allow for easy updating/pushing via Spacewalk. Some of the RPM packages I'm building involve a crontab, which I've placed in /etc/cron.d/.
The Problem:
The cron files placed in /etc/cron.d/$scriptname_cron were not being loaded into crond. You could watch the cron log file /var/log/cron and cron would never "reload" the crontab including the new file.
The Reason:
The reason why this occurred was because the timestamp on the file in /etc/cron.d matched when the RPM was built, which may have been months beforehand. Therefore crond ignored the file.
The Fix:
I added the following to the SPEC file:
Code:
%post
touch /etc/cron.d/$FILE_NAME
#where $FILE_NAME is the File Name in /etc/cron.d.
Alternatively, touching the file after installing would fix this as well.
I've seen multiple postings online (
EXAMPLE) about this (or a very similar situation) so I wanted to put this out there to hopefully help the next guy running into this.
Relevant XKCD
Thanks,