This site contains affiliate links — we may earn a commission if you sign up through them. Details
Guide · Cron & Automation

What is a Cron Job? How to Set Up Cron on Thai Hosting 2026

What is a Cron Job? How to Set Up Cron on Thai Hosting 2026

A Cron Job is a scheduled task that runs automatically at specified intervals on your hosting server. The name "cron" comes from the Greek word for time (chronos). Cron jobs are essential for automating repetitive tasks like database backups, email newsletters, sitemap updates, cache clearing, and log rotation — without any manual intervention.

Cron Expression Syntax

A cron expression consists of 5 time fields followed by the command to execute:

* * * * * command
| | | | |
| | | | └── Day of week (0=Sun, 1=Mon...6=Sat)
| | | └──── Month (1-12)
| | └────── Day of month (1-31)
| └──────── Hour (0-23)
└────────── Minute (0-59)

Use * for "any value", numbers for specific values, */n for "every n units", and commas for multiple values.

Common Cron Expression Examples

RecommendedAsiaGB.com — Web Hosting & VPS we recommend. Servers in Thailand & Singapore, SSD storage, DirectAdmin control panel, 24/7 Thai-language support, 99% uptime.

Based in Thailand, ideal for Thai websites and businesses.

Visit AsiaGB →

Creating Cron Jobs in DirectAdmin

  1. Login to DirectAdmin → Advanced FeaturesCron Jobs.
  2. Fill in the Minute, Hour, Day, Month, Weekday fields and the Command.
  3. Example — daily database backup at 2AM:
    /usr/bin/mysqldump -u dbuser -p'dbpass' dbname > /home/user/backup/db_$(date +\%Y\%m\%d).sql
  4. Click Add Cron Job.

WordPress WP-Cron

WordPress has its own scheduling system called WP-Cron, which runs wp-cron.php every time a visitor loads a page. The problem: if your site has no visitors, scheduled tasks won't run.

Solution: Disable WP-Cron and create a real server cron job instead:

# In wp-config.php, add:
define('DISABLE_WP_CRON', true);

# Create a real cron job in DirectAdmin:
*/5 * * * * /usr/bin/php /home/user/public_html/wp-cron.php > /dev/null 2>&1

Popular Cron Job Use Cases

Troubleshooting Cron Jobs

Frequently Asked Questions

What is the most frequent interval a cron job can run?

Every 1 minute (*/1 * * * *) is the minimum for standard cron. However, many hosting providers restrict cron to run no more frequently than every 5 minutes. Check your hosting provider's cron policy.

How do I know if a cron job failed?

Cron typically emails the account when a job fails, if MAILTO is configured. Alternatively, add error log redirection at the end of your command: 2>> /tmp/cron-error.log

What happens if a cron job runs longer than its scheduled interval?

Cron will start a new instance overlapping the still-running job, potentially causing race conditions or data corruption. Prevent this using lock files or the flock command.

What's the difference between cron jobs and WordPress Scheduled Posts?

WordPress Scheduled Posts use WP-Cron, which only runs when visitors load pages. If your site has low traffic, posts may publish late. Setting up a real server cron job to trigger WP-Cron every 5 minutes fixes this reliably.