Configuring cron jobs on DreamHost
Setting up cron jobs via control panel interface.
To add the cron via the administration panel, visit:
https://panel.dreamhost.com/index.cgi?tab=goodies&subtab=cron&
And add a new cron tab using the following command:
/usr/bin/lynx -source http://example.com/cron.php > /dev/null 2>&1
To add a cron job 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 * * * /home/user/script.pl
- 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.
