Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using vixie cron on Debian/Ubuntu. How to set a custom directory to be read by cron? I want to lead crontab to run commands found in a series of files, e.g.

/home/cron/*.cron

or perfectly

/home/*/cron/*.*

In fact, instead of putting cron commands in /var/spool/cron/crontab/root, I want to spread commands in these folder.

Is it possible and recommended to use include for calling other files within root file?

share|improve this question
    
@Mat, I'm using Debian/Ubuntu; thus, the default cron is vixie, if it's what you mean. –  All May 27 '12 at 8:13
add comment

1 Answer

up vote 2 down vote accepted

Cron in debian reads commands from 3 locations - first is users crontabs in /var/spool/cron/crontabs/$user, then it reads global /etc/crontab and then all files from /etc/cron.d.

But you can't easily have multiple crontabs per user. Only files in /var/spool/cron/crontabs are per-user. The other two are system-wide and each line contains a username, under which is the command run. You could integrate/link those individual files into /etc/cron.d, but users would be able to run commands under root or other user.

So if one crontab per user is OK, just make links from your location to /var/spool/cron/crontabs. If you need multiple per user, then you need to make a script which will take your users's cron files, and modify it for system-wide crontab (that means adding a field with their username) and adding those under /etc/cron.d.

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.