How to Set-up a Crontab File

Thank goodness for CrunchBang ~ Howto Set-up a Crontab File.

I’ve been editing existing crontab files for months but never set up my own for drupal.

While there’s a lot of documentation with drupal on what cron jobs are and how you might want to configure one there’s some steps missing.

  1. The first thing I needed to do was ssh to my server
  2. Now that I’m authenticated I run
    crontab -l

    to list all my cron jobs.
    If you have none then you can create a fresh one. That’s what I needed to do

  3. crontab -e

    created a blank crontab file

  4. Now (for my set up) I’m in the vim editor (see if you need vim cheatsheet), I pasted in the recommended cronjob entry from the install.txt:
     0   *   *   *   *   wget -O - -q -t 1

    with an edit to the site url of course. I also added

    >/dev/null 2>&1

    which ensures that I don’t get an email each time the cron job is run.

  5. I have several sites so I repeated that for a couple of other sites with some variation. Some sites only need to be updated daily for example.
  6. The I needed to exit the editor. Hit ‘esc’ to exit edit/insert mode
  7. Then save and close the vim editor
  8. Last I ran <code>crontab -l</code> again to see if everything was there.

Here’s an example of my cron job list:

[vid@myServer ~]$ crontab -l
0   *   *   *   *   wget -O - -q -t 1 >/dev/null 2>&1 #Run this on the hour
5   *   *   *   *   wget -O - -q -t 1 >/dev/null 2>&1 #Run this at 5 min past the hour
10   0   *   *   *   wget -O - -q -t 1 >/dev/null 2>&1 #Run this daily at 10 min past midnight
15   0   *   *   *   wget -O - -q -t 1 >/dev/null 2>&1 #Run this daily at 12:15 am
20   0   *   *   *   wget -O - -q -t 1 >/dev/null 2>&1 #Run this daily at 12:20 am
Leave a Comment