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

I have a lab of computers running Ubuntu 9.10. Most of the people who log on to these computers are users from an LDAP server, and not local users. We discovered that if an LDAP user has a crontab with an entry marked to be run @reboot, the command will not actually run upon the reboot of a machine.

I'm pretty sure that this is because the cron daemon starts before networking is fully up, so the crontabs of any LDAP users aren't loaded and run or checked for @reboot. In fact, cron will ignore LDAP users' crontabs entirely after a reboot until that user runs crontab -e again and saves, or until the cron daemon is rebooted.

We were able to fix one part of this problem by adding the following line to /etc/crontab:

@reboot root /bin/sleep 45 && /etc/init.d/cron restart

Thus, when cron starts back up upon a reboot, it waits for networking to get up, then restarts the cron daemon. That fixes the problem of crontabs not being read at all for LDAP users. However, since it's the cron daemon being restarted and not the computer, @reboot entries are ignored.

Is there a way for a user to make a command run upon restarting the daemon, rather than a reboot? Or is there a better solution to this overall problem?

Thanks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Sounds like you have a race condition where cron is scanning its tabs and not finding a valid user for some of them because the network/LDAP server can't be reached -- You need to make sure your user list is accessible before cron starts up.

Try adjusting your RC sequence so cron is not started until after the network is fully up (either by re-arranging rc.d or marking in the cron script that it requires networking to be started first).

share|improve this answer
    
That was actually one thing I was going to try, but I forgot to try it. Unfortunately, 9.10 starts cron using Upstart rather than System-V, and I can't figure out how Upstart works, despite my googling. Would you happen to know how to set Upstart to start cron after networking is up? –  Ben Torell May 20 '10 at 19:47
    
Nevermind, I figured it out. I set cron to start after networking, and @reboot now works! Thanks! –  Ben Torell May 20 '10 at 20:13
1  
@Ben: For the benefit of future readers, please post information on how you made that change (either as an edit to your question or an additional comment or, if appropriate, as an answer). I'm assuming you edited /etc/init/cron.conf and changed the dependency. –  Dennis Williamson May 20 '10 at 21:42
    
Incidentally you may want to report that to the Ubuntu folks as a bug if nobody has: If you're in a NIS environment you'd probably see the same breakage since no network means no user info... –  voretaq7 May 21 '10 at 3:14
    
@Dennis: Yes, that's what I did. To be honest, I don't know if the change I made was optimal or ideal (due to my limited understanding of Upstart), but it works. I'll post what I did to fix it once I get the chance. –  Ben Torell May 22 '10 at 16:52

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.