Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Create and Schedule Cron Jobs in DirectAdmin

A cron job runs a task for you at a set time. This guide shows you how to add one in DirectAdmin.

DirectAdmin2 min read6 steps6 screenshots

What is a cron job?

A cron job is like an alarm clock for your website. When the time comes, it runs a command or a script (a small program) by itself. People use cron jobs to clear old files, send reports or run a website's regular tasks.

Understand the time boxes

DirectAdmin gives you five boxes for the time. Each one is a part of the schedule.

BoxWhat it meansAllowed values
MinuteMinute of the hour0 to 59
HourHour of the day0 to 23
Day of monthDate in the month1 to 31
MonthMonth of the year1 to 12
Day of weekWeekday0 to 7 (0 and 7 mean Sunday)

A star * means "every". So 30 2 * * * means every day at 2:30 in the morning.

Steps

  1. Log in to DirectAdmin.
  2. Open Advanced Features and click Cron Jobs.
    Screenshot: Open Advanced Features and click Cron Jobs .
  3. Click Create Cron Job, or find the form on the page.
    Screenshot: Click Create Cron Job , or find the form on the page.
    Screenshot: Click Create Cron Job , or find the form on the page.
  4. Fill in the five time boxes.
  5. In the Command box, type what should run. Example:
php /home/username/domains/example.com/public_html/task.php

This line runs a PHP file. Replace username, the domain and the file name with your own.

  1. Click Create.

Edit or delete a cron job

Go back to Cron Jobs. Use the edit link beside a job to change it, or the delete link to remove it. Warning: a wrong command can break a site, so test it carefully.

Get emails about results

Some versions have a box for an email address. The server sends the output of each run there. This helps you see if a job fails. Add > /dev/null 2>&1 at the end of the command to stop these emails.

Tip: Do not run a job every minute unless you really need it. Too many jobs slow your hosting down.

Quick recap

  • A cron job runs a command on a schedule.
    Screenshot: A cron job runs a command on a schedule.
    Screenshot: A cron job runs a command on a schedule.
  • Open Advanced Features, then Cron Jobs.
    Screenshot: Open Advanced Features , then Cron Jobs .
  • Set minute, hour, day, month and weekday, then add the command.
  • A star means "every".
  • Test your command before relying on it.