Knowledge Base

Setting up cron jobs

A cron job runs a command or script automatically on a schedule, for example every hour or once a day. Websites use them for tasks such as sending scheduled emails, clearing caches or running WordPress's scheduled tasks.

Adding a cron job

  1. Log in to DirectAdmin.
  2. Go to Advanced Features and click Cronjobs.
  3. Set when it should run using the minute, hour, day of month, month and day of week fields.
  4. Enter the command to run.
  5. Create the cron job.

Setting the schedule

Use * to mean "every", */15 to mean "every 15" and commas for a list.

Minute Hour Day of month Month Day of week Runs
*/15 * * * * Every 15 minutes
0 * * * * Every hour, on the hour
30 2 * * * Every day at 2:30am
0 9 * * 1 Every Monday at 9am

Times follow the server's time zone. Please don't run cron jobs more often than once every 5 minutes. Jobs set to run more often are adjusted and we'll let you know. See our Fair Use and Backup Policy.

Example commands

Run a PHP script:

/usr/local/bin/php /home/yourusername/domains/yourdomain.com/public_html/cron.php

Run WordPress's scheduled tasks:

/usr/local/bin/php /home/yourusername/domains/yourdomain.com/public_html/wp-cron.php

Replace yourusername and yourdomain.com with your own details.

Stopping cron emails

By default, anything a cron job outputs is emailed to you. To stop these emails, add this to the end of the command:

>/dev/null 2>&1
Please rate this article to help us improve our Knowledge Base.

0 0