Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

is there a way to use multiple crontab files for one user? Thinking something along the lines of crontab file per project instead of crontab per user...

Any help is appreciated...

share|improve this question

migrated from stackoverflow.com Feb 18 '12 at 3:30

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

It's generally a good idea to maintain your crontab in a separate file anyway, and install it with crontab filename. (I keep my crontab file in a source control system.)

You could have multiple crontab files, and install them all with

cat file1 file2 file3 | crontab

The crontab command normally only manages a single crontab per user. But you can add system crontab files to the /etc/cron.d directory. These files have an extra field after the time specification that indicates the user for the job, and you can have multiple files per user. Even if one of them has a syntax error, the others will still execute.

You'll need root access to install files in that directory.

man 5 crontab for details.

I'm not convinced that circumventing the normal crontab mechanism like this is a good idea, but it should work.

(This assumes the "Vixie Cron" implementation, which is probably what your system uses.)

share|improve this answer
    
I did that today. That would be easy to do, but the goal with this is that each project "manager" would have control over his own crontab. With that approach it would have to be combined like that each time someone changes one of the files, which means they will have to keep track of all the files that need to be compiled –  realshadow Feb 18 '12 at 0:22
    
So create a program (or script, or whatever) to automate it. Note that you can invoke the crontab command from a crontab entry. –  Keith Thompson Feb 18 '12 at 0:42
    
Yes that wouldnt be a problem, but wouldnt that create a small problem? When you combine lets say 10 different files (aka from 10 different people) and one of them has wrong syntax, crontab wont install, but I would have to manually check each file to see who has a syntax error. Unless there is some cron syntax checker... Thats why I was asking if you can have multiple crontabs where cron manages them –  realshadow Feb 18 '12 at 10:16
add comment

Why would you do that? You could use multiple lines in crontab - I think that would do the job too.

There are also the directories you could probably use:

cron.d/
cron.daily/
cron.hourly/
cron.monthly/
cron.weekly/
share|improve this answer
    
Thats how it is now :) I just would like to know if there is a way to do this –  realshadow Feb 17 '12 at 22:58
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.