If a cron script in /etc/cron.d has a . in the file name, then it will not run! ref configs with dots in file name not working in /etc/cron.d

Configuration (System)



To email the output of your cron job to a specific user, add the following at the top of your cron script:

To stop emails:


…or pipe the output of your command to a file (see Logging below)…


To write output to a log file, add the following after your command:

>> /home/my-user-name/logs/update_index.log 2>&1

Note: This re-directs stdout AND stderr which isn’t much good if you are doing a SQL dump to stdout. In this case, try something like this:

mysqldump --host=localhost --user=patrick --password=mypassword redmine > $DUMP_FILE 2>> $LOG_FILE


System cron tasks are configured from the /etc/crontab file. The /etc/crontab file is set-up to run commands hourly, daily, monthly and weekly:


To set-up a task to run at these times, just add your shell script to the relevant folder:



Check your shell script file name does NOT have an extension. For details, see run-parts doesn’t run script with sh extension


To run a command at a different time, setup your file in the /etc/cron.d folder. Note: The files in this folder are in crontab format with the user inserted before the command (see Sample, System below):



It is probably less confusing to use the global cron system for jobs on a server. It Will be easier to work out which processes are being run…

To view your own crontab file:

crontab -l

To edit your own crontab file:

crontab -e

To edit the crontab file of another user:

crontab -e -u username




# minute  (0-59),
# |       hour (0-23),
# |       |       day of the month (1-31),
# |       |       |       month of the year (1-12),
# |       |       |       |       day of the week (0-6 with 0=Sunday).
# |       |       |       |       |       user        commands
  0       0       *       *       *       myusername  /usr/bin/python2.4 /home/USERNAME/scripts/ --archive-type=zip --num-backups=10 /home/USERNAME/svn/REPOSITORY_NAME/ /home/USERNAME/backup/svn/


A nice looking cron script layout (from the link below):
# minute (0-59),
# |       hour (0-23),
# |       |       day of the month (1-31),
# |       |       |       month of the year (1-12),
# |       |       |       |       day of the week (0-6 with 0=Sunday).
# |       |       |       |       |       commands
  0       0       *       *       *       /usr/bin/python2.4 /home/USERNAME/scripts/ --archive-type=zip --num-backups=10 /home/USERNAME/svn/REPOSITORY_NAME/ /home/USERNAME/backup/svn/

Backing up your Subversion (SVN) repository on Dreamhost with cron


This sample does not include the user parameter. The user parameter is required for scripts in cron.d.

Working Hours

Cron Job every weekday during working hours. This example checks the status of the database every weekday (i.e. excluding Sat and Sun) during the working hours 9 a.m – 6 p.m:

00 09-18 * * 1-5 /home/ramesh/bin/check-db-status
00     0th Minute (Top of the hour)
09-18  9am, 10am, 11am, 12am, 1pm, 2pm, 3pm, 4pm, 5pm, 6pm
*      Every day
*      Every month
1-5    Mon, Tue, Wed, Thu and Fri (Every Weekday).