TL;DR Cron Job
A cron job is a scheduled task that runs automatically on a server at a defined time or interval without any manual input. The name comes from the Unix time-based job scheduler called cron, and the tasks themselves can be anything from sending emails and generating reports to clearing caches and running database maintenance scripts. WordPress relies heavily on cron jobs through its own internal scheduler, WP-Cron, which handles things like publishing scheduled posts, checking for plugin updates, and triggering automated backups. Because CloudSonic gives you full root access to your server, you can set up real server-level cron jobs directly rather than relying on WordPress's less reliable pseudo-cron system, giving you more control and better timing accuracy for critical tasks.
How a Cron Job Works
The cron daemon is a background process that runs continuously on a Linux server and checks a configuration file called the crontab at regular intervals, typically every minute. The crontab contains a list of scheduled tasks, each with a time expression that specifies when it should run and a command to execute when that time arrives. The time expression uses five fields representing minute, hour, day of month, month, and day of week, allowing you to schedule tasks to run at almost any interval from every minute to once a year. When the scheduled time arrives the cron daemon executes the command automatically without any user input required. The command can be anything the server can run, a PHP script, a shell command, a Python script, or a call to an external API.
# Edit your crontab
crontab -e
# Run a PHP script every hour
0 * * * * /usr/bin/php /var/www/mysite/cron.php
# Clear WordPress transients every day at 3am
0 3 * * * /usr/bin/wp transient delete --all --path=/var/www/mysite/public_html --allow-root
# Run a database backup every day at 2am
0 2 * * * /usr/local/bin/sonic-backup mysite
# Run a script every 15 minutes
*/15 * * * * /usr/bin/php /var/www/mysite/queue.php
# Disable WP-Cron in wp-config.php and replace with real cron
define('DISABLE_WP_CRON', true);