Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

On my Ubuntu server (LTS 12.04) I would like crond to be running every time I boot up. Where should I configure this? I took a look at service --status-all and saw that cron was there, but it was marked with a question mark.

In general, where should a user add daemons that they want to be executed at boot?

share|improve this question
    
If you have cron installed, then it should already automatically be starting at boot. You asked for general answers, so the answers are general. But in your particular case, I'd focus on checking for certain that cron isn't starting up, and if it isn't then why. Otherwise you may end up trying to start cron twice, and if your original issue gets resolved for some other reason, you may have problems. –  Robie Basak Jan 25 '13 at 9:33
add comment

2 Answers 2

Normally you add the script that starts a daemon into /etc/rcS.d/ (the S means at Startup) and the script should automatically be launched the next time you boot. (Generally you softlink scripts there from their original path.) This can also be done with the update-rc.d tool {requires root privileges}.

Sadly I'm not sure where exactly the crond starter script is, but it should be automatically configured for you to start up at boot, and before playing with system directories I would say that make a sanity check and see wht happens if you run crontab -e and add in a new line like this: */1 * * * * echo "Cron works", and you should get the string Cron works in a system mail (provided that you have postfix configured).

Also don't forget to remove the cronjob once it has been tested as it will send that string every minute to you and it quickly gets annoying.

share|improve this answer
add comment

According to Andreas Poisel in a similar thread over at stackoverflow,

  • To run a daemon or any command as root before login, add it to /etc/rc.local or add a cron job with @reboot as its time field. You can also write a proper init script based on /etc/init.d/skeleton.

  • To run a command after login, add it to ~/.bash_profile (provided you're using bash). Contrary to ~/.bashrc, this file will be executed by login shells only.

  • To run a command after login of any new user, add an appropriate .bash_profile to /etc/skel and new users will get this file automatically on account creation.

share|improve this answer
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.