[Tfug] /etc/crontab vs /etc/cron.*

Jesse Allen jesse.carl at gmail.com
Thu Nov 20 08:45:49 MST 2008


On Wed, Nov 19, 2008 at 02:07:06PM -0700, Christopher Robbins wrote:
> Is there any difference between setting scripts to runvia crontab versus
> dropping a copy in /etc/cron.* (daily/hourly/weekly)?
> 
> I understand that crontab runs the scripts within the
> /etc/cron.* directories, but I'm wondering if there's any
> specific advantage to one or the other...I've always used
> the respective directories, but is there a difference between
> the two?

There are three ways to set up cron jobs:

1. crontab -e :
    - uses the format: m h dom mon dow command
    - good for inividual users
    - can be used as su

2. /etc/cron.(hourly|daily|weekly) :
    - drop executable script in folder
    - runs each script in folder in the same order as ls
    - good for general su scripts without specific times
    - folder can be configured to run at any time within
      hour, day, or week

3. /etc/cron.d/
    - create text file in folder with format:
        m h dom mon dow user command
    - can specify time and user
    - good for more complex cron tasks
    - good for cron tasks set up by applications

I tend to use /etc/cron.d and /etc/cron.(hourly|daily|weekly) for most
of my needs, but crontab -e can be quite nice if you don't have a lot of
tasks. I hope that helps.

- Jesse Allen





More information about the tfug mailing list