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.

I have 5 web applications. The directory structure is similar to following:

/var
   `-  /www
            `- /domains
                      `-  /domain1
                                 `- /public_html
                                               `- /crontabs
                                                        `- /crons
                      `-  /domain2
                                 `- /public_html
                                               `- /crontabs
                                                        `- /crons
                      `-  /domain3
                                 `- /public_html
                                               `- /crontabs
                                                        `- /crons
                               .
                               .
                               .
                               .
                               .

Each application has its own list of crons [and these files contain valid, crontab -e like, syntax]. At the moment as this is a test and isolated server so all applications run under the same user. I know about crons, /etc/cron.d, /etc/cron.interval (interval = hourly|daily|weekly), /var/spool/crontabs/.

My question: is there an alternate to /etc/cron.d but user specific where i could just symlink these crons and they would be executed? I would prefer such a solution because these crons get updated at times from developers.

On #ubuntu ikonia suggested to google on how could one include crons, i did and couldn't find such a solution. If there could be place where i could do:

include /var/www/domains/*/public_html/crontabs/crons

that would be totally awesome.

[EDIT] I am open to changing the crons files a little.

share|improve this question

2 Answers 2

Root-level crontabs can be symlinked into /etc/cron.d/ . Everything in that folder is executed as root. It's possible for a root-level crontab entry to be executed as user-level, but that's a workaround and beyond the scope of the question. An example of such a symlink:

# ln -s /path/to/crontab /etc/cron.d/

User-level crontabs cannot be created by symlink or any kind of direct file management - crontab management is specifically designed to prevent users from doing that. All user-level crontabs must be created using the 'crontab' command, so that all user-level crontabs get checked for syntax, and get spooled in the same place.

Happily, the 'crontab' does more than merely open an editor. The command will accept entire files. For example, for the user owning $DomainName,

$ crontab /var/www/$DomainName/public_html

So it should be quite easy to add a user-level crontab to the webapp startup script.

share|improve this answer

On my web server, I give every virtual server a own linux user. Every linux user has its own crontab.

share|improve this answer

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.