Cron Jobs & Scheduled Tasks

How to Set Up a Cron Job

Published · Updated 3 min read
Knowledge base article
Contents (12 sections)

Cron jobs are scheduled tasks that run automatically at specified intervals. Common uses include sending email digests, cleaning up temporary files, running database maintenance, and triggering WordPress cron events.

Setting Up Cron Jobs in cPanel

  1. Log in to cPanel.
  2. Go to Advanced > Cron Jobs.

[screenshot: cPanel Cron Jobs page]

Quick Presets

cPanel provides common schedule presets:

  • Once per minute (`* * * * *`)
  • Once per five minutes (`*/5 * * * *`)
  • Once per hour (`0 * * * *`)
  • Once per day (`0 0 * * *`)
  • Once per week (`0 0 * * 0`)
  • Once per month (`0 0 1 * *`)

Creating a Cron Job

  1. Select a Common Setting preset or enter custom timing.
  2. In the Command field, enter your script command.
  3. Click Add New Cron Job.

Common Commands

Run a PHP Script

code
/usr/local/bin/php /home/username/public_html/cron.php

Run WordPress Cron

code
/usr/local/bin/php /home/username/public_html/wp-cron.php

Curl a URL

code
/usr/bin/curl -s https://yourdomain.com/cron-endpoint > /dev/null 2>&1

Tip: Add `> /dev/null 2>&1` at the end of commands to suppress output. Without this, cPanel sends you an email for every cron execution.

Setting Up Cron Jobs in DirectAdmin

  1. Log in to DirectAdmin.
  2. Go to Extra Features > Cron Jobs.
  3. Enter the schedule (minute, hour, day, month, weekday).
  4. Enter the command.
  5. Click Add.

Cron Schedule Format

code
* * * * *
| | | | |
| | | | └── Day of week (0-7, 0 and 7 = Sunday)
| | | └──── Month (1-12)
| | └────── Day of month (1-31)
| └──────── Hour (0-23)
└────────── Minute (0-59)

Examples

ScheduleMeaning
`0 */6 * * *`Every 6 hours
`30 2 * * *`Daily at 2:30 AM
`0 9 * * 1`Every Monday at 9 AM
`0 0 1 * *`First day of every month at midnight
`*/15 * * * *`Every 15 minutes

Managing Cron Jobs

Editing

  1. Go to Cron Jobs.
  2. Find the job in the list.
  3. Click Edit.
  4. Modify the schedule or command.
  5. Save.

Deleting

  1. Click Delete or Remove next to the cron job.
  2. Confirm deletion.

Best Practices

  1. Test your command first — run it manually via SSH or Terminal to ensure it works.
  2. Suppress output — use `> /dev/null 2>&1` to avoid email spam.
  3. Use full paths — always use absolute paths for PHP, scripts, and files.
  4. Be careful with frequency — running crons too often wastes resources.
  5. Log output — redirect to a log file for debugging: `>> /home/user/cron.log 2>&1`

Warning: Resource-intensive cron jobs (database operations, large file processing) can affect your hosting performance. Schedule them during off-peak hours.


Need help? Contact our support team at https://domainindia.com/support/client/support.

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
How to Set Up a Cron Job