Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to implement a configuration mechanism that allows in a certain project to deploy through svn a cron configuration.

I immediately thougt that what I should do is cerate symlinks from /etc/cron.d/ to my project's cron file (which in turn is controlled by a vcs), but that seems to not be working.

I found some old forum messages referring that symlinks were not supported and other saying that they are. Which is it?

Is there anything else or any other good way to achieve this?

share|improve this question

According to man crond


All crontab files have to be regular files or symlinks to regular files, they must not be executable or writable for anyone else but the owner. This require‐ ment can be overridden by using the -p option on the crond command line. If ino‐ tify support is in use, changes in the symlinked crontabs are not automatically noticed by the cron daemon. The cron daemon must receive a SIGHUP signal to reload the crontabs. This is a limitation of the inotify API.

The syslog output will be used instead of mail, when sendmail is not installed.

It annoyed the living crap out of me as well, In short yes you can use symlinks however, if not a regular files or symlinks to a regular file it must use -p switch.

share|improve this answer
You will also find that the file must be owned by the user cron is running jobs for; for example, if a symlink /etc/cron.d/bobsjob points to a file owned by user "bob" cron will fail with a syslog message WRONG FILE OWNER (/etc/cron.d/bobsjob). – Craig Ringer Nov 16 '12 at 2:43
@CraigRinger I have a user named "www-data" owning the cron file, I'm currently getting the WRONG FILE OWNER error in the syslog. How can I make Cron execute using the user "www-data". I don't want to make root own the file. – CMCDragonkai Jan 10 '14 at 18:47
@CMCDragonkai sudo -u www-data crontab -e and add it to the www-data user's crontab. It'll then run as user www-data. Remember to remove the explicit user column, since it doesn't exist in user crontabs. – Craig Ringer Jan 11 '14 at 3:13
Will that place the file inside etc/cron.? I was under the impression crontab tool would place the task somewhere else. – CMCDragonkai Jan 11 '14 at 10:26

This has security implications. The scripts in /etc/cron.d/ are run by root with root privileges. It's a bad idea to symlink scripts there that are owned and writable for non-root users, since your system could be compromised that way

share|improve this answer

I'd check the cron manpage for your version of Ubuntu (I assume we're talking Ubuntu on this forum!):

Files in this directory have to be owned by root, do not need to be executable (they are configuration files, just like /etc/crontab) and must conform to the same naming convention as used by run-parts(8): they must consist solely of upper- and lower-case letters, digits, underscores, and hyphens. This means that they cannot contain any dots.

As Florian points out, if this file is writable by non-root users, it's a security hole because the jobs will be run by root (for whoever is named as the job owner in the file). Also note, therefore, that

This directory can contain any file defining tasks following the format used in /etc/crontab, i.e. unlike the user cron spool, these files must provide the username to run the task as in the task definition.

i.e. pop the username in before the command to run.

share|improve this answer

Your Answer


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.