Configuring cron jobs with DreamHost

Last updated on
5 August 2016

On DreamHost you can configure cron jobs using either the web panel or the shell.

Setting up cron jobs using the web panel


Click 'Add a New Cron Job' and enter the following command:
curl --silent --compressed

Note: The above code is dependent on http being accessible. If you want to run a cron job on a password protect domain, use the include the following with the absolute path for your domain to cron.php instead of the example:
/dh/cgi-system/php5.cgi /home/username/

In the same interface, you should specify a title (such as 'Drupal Cron'), e-mail address for results (not recommended), and a run interval. If you have more than one Drupal site, you can add more than one command per cron job (one per line).

Setting up cron jobs using the shell

This information comes from the Dreamhost knowledge base.

Via the "crontab" command from the shell.

crontab -l will show you your currently set up cron jobs on the server.
crontab -r will delete your current cron jobs.
crontab -e will allow you to add or edit your current cron jobs by using your default text editor to edit your "crontab file".

Your crontab includes all the cron jobs you'd like, with one cron entry per line. A cron entry looks like this:

45 2 * * * curl --silent --compressed

    The first number is the minute of the hour for the command to run on.
    The second number is the hour of the day for the command to run on.
    The third number is the day of the month for the command to run on.
    The fourth number is the month of the year for the command to run on.
    The fifth number is the day of the week for the command to run on.

Here are some examples to help you learn the syntax for the numbers:

    32 * * * * : will be run every hour on the 32nd minute.
    12,42 * * * * : will be run twice an hour on the 12th and 42nd minutes.
    */15 */2 * * *: will be run at 0:00, 0:15, 0:30, 0:45, 2:00, 2:15, 2:30, ...
    43 18 * * 7: will be run at 6:43pm every Sunday.

You can also edit crontab on a local file. Upload it to a directory and run:

crontab YourFileName

It'll replace your crontab with what's on the text file, without having to edit it online. This is useful if you're using a telnet client which doesn't support ANSI control codes (such as the Windows' one) and can't understand what the heck is going on on the editors.

In my own experience, I found that only by entering one cron command per line worked (one line each for :10, :20, :30, etc.). I could not get crontab to take the "*/15" argument, so I worked around it. Also, if you have ANY character after the last command (space, CR, whatever) the file will not take.

I like this file-load approach because I have a basic command file to edit or call up again if needed. Afterwards, running crontab -l will confirm that the job did take.