Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running a few CentOS servers on EC2. We're working to run them all from one image and mount all the variant configuration files from persistent storage.

We just started mounting cron directories from persistent storage, and I'm finding that the cron jobs are no longer running. Can cron configuration files be mounted? Is there something else that I should be keeping an eye on here?

They're getting mounted with -obind. After they're mounted, the result of the mount command returns:

/mnt/persistent/conf/cron/cron on /var/spool/cron type none (rw,bind)
/mnt/persistent/conf/cron/cron.daily on /etc/cron.daily type none (rw,bind)
/mnt/persistent/conf/cron/cron.monthly on /etc/cron.monthly type none (rw,bind)
/mnt/persistent/conf/cron/cron.weekly on /etc/cron.weekly type none (rw,bind)
/mnt/persistent/conf/cron/cron.hourly on /etc/cron.hourly type none (rw,bind)

Edited to answer questions

Latest contents of /var/log/cron show that normal functioning stopped on the 13th, when this new configuration took over.

Jun 13 02:01:01 ip-10-70-153-178 crond[11389]: (root) CMD (run-parts /etc/cron.hourly)
Jun 13 02:10:01 ip-10-70-153-178 crond[11502]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun 13 02:20:01 ip-10-70-153-178 crond[11504]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun 13 02:30:01 ip-10-70-153-178 crond[11530]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun 13 02:40:01 ip-10-70-153-178 crond[11532]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun 13 02:50:01 ip-10-70-153-178 crond[11534]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun 13 03:00:01 ip-10-70-153-178 crond[11536]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jun 13 03:01:01 ip-10-70-153-178 crond[11538]: (root) CMD (run-parts /etc/cron.hourly)
Jun 13 03:02:01 ip-10-70-153-178 crond[1740]: (CRON) STAT FAILED (cron)
Jun 15 17:54:11 ip-10-70-153-178 crontab[18321]: (root) LIST (root)
Jun 15 17:57:47 ip-10-70-153-178 crontab[18322]: (root) BEGIN EDIT (root)
Jun 15 17:57:49 ip-10-70-153-178 crontab[18322]: (root) REPLACE (root)
Jun 15 17:57:49 ip-10-70-153-178 crontab[18322]: (root) END EDIT (root)
Jun 17 06:49:32 ip-10-70-153-178 crontab[24613]: (root) LIST (root)
Jun 17 06:50:05 ip-10-70-153-178 crontab[24643]: (root) LIST (root)
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

What do you see in /var/log/cron? This ought to work. You could replace the bind mounts with symlinks, which is arguably a simpler solution. That is:

ln -s /mnt/persistent/conf/cron/cron.daily on /etc/cron.daily

I don't think that in this situation bind mounts are buying you anything other than complexity.

To further debug cron:

  • Stop your cron service (/sbin/service crond stop).
  • Run cron with some of the debug flags available with the -x option

For example:

crond -n -x pars

This will show details on crontab parsing. Some of these options may yield useful information.

share|improve this answer
    
Edited question to add /var/log/cron –  Laizer Jun 17 '11 at 14:11
    
I've updated my answer with some information on getting better debugging out of cron. However, I would also recommend experimenting with replacing the bind mounts with symlinks and see if the behavior is any different. –  larsks Jun 17 '11 at 14:20
    
Thanks - this did help out - just the tips on starting and stopping the service, checking the logs, and getting the debug info. I did get it all running with it mounted. –  Laizer Jun 17 '11 at 19:09
    
What was the problem? The answer might be helpful to someone else someday. –  larsks Jun 17 '11 at 19:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.