Let’s explore the basics of cron! Servebolt operates with a server-based scheduling tool commonly used in Linux systems to automate repetitive tasks, such as update checks, session management, sitemap regeneration, inventory updates, and more. We will cover the benefits of using server-side cron, adding cron jobs, and some best practices for writing cron jobs.
Faster and More Reliable Scheduled Tasks with Server-Side Cron
While some content management systems (CMS), such as WordPress and Drupal, provide built-in cron and task management features, these solutions often hinder performance, especially for high-traffic websites. Built-in cron jobs frequently execute tasks during website visits, leading to resource contention and performance bottlenecks.
Our server-side cron offers a more reliable and efficient approach to scheduling tasks. By operating independently in WordPress, Drupal, or Magento, your cron jobs can execute tasks in the background without impacting website performance or user experience. This ensures that critical tasks are executed promptly and reliably, even for websites with a low volume of visitors.
Cron Job Best Practices
- Efficient script execution: Instead of triggering scripts via HTTP (using
wget
,curl
, etc.), execute scripts directly using PHP or the shell. This approach is more efficient and consumes fewer resources. - Minimum cron job frequency: Run cron jobs as infrequently as possible to minimise resource consumption and reduce the workload on the server and databases.
- Prevent overlapping cron jobs: If multiple cron jobs run simultaneously, ensure they don’t overlap; utilise the ‘flock’ command to introduce delays between cron jobs. For WordPress, this can easily be set up with our Servebolt Optimizer plugin.
- Thorough testing: Manually test your cron jobs to verify their functionality and ensure they operate as intended. For WordPress installations, you can run the following command to run all WordPress cron manually:
wp cron event run --all
This command forces WordPress to execute all scheduled cron jobs immediately. Additionally, running this command will display any errors created during the execution of your cron jobs. Please refer to this article for more detailed information on debugging cron errors.
Servebolt’s server-side Cron jobs are executed based on the Default PHP Timezone configured for the site. This means the scheduled time for a Cron job aligns with the PHP timezone setting, which can be customised per site.
Adding Cron Jobs in the Servebolt Admin Panel
Servebolt’s integrated cron support within our Admin Panel simplifies setting up cron jobs. This eliminates the need to manage complex crontab files manually. The Cron Job interface enables you to schedule, manage and customise your cron jobs.

If you need help figuring out the cron schedule, this resource should be very helpful.
Cron syntax is used to specify the execution time. The following example demonstrates how to run the cron.php
script in the public folder every five minutes:
*/5 * * * * /usr/bin/php ~/site/public/cron.php
To add a second cron job that runs at the same intervals but with a 30-second delay, use the following command:
*/5 * * * * sleep 30 && flock -n /tmp/cron_job_2.lock /usr/bin/php ~/site/public/cron_job_2.php
Paths to Common Commands
The following are the paths to some of the most common commands used in cron jobs:
/usr/bin/php
: The PHP interpreter/usr/bin/sh
: The Bourne-again shell (Bash)/usr/bin/wget
: The GNU wget downloader
Should you have any additional questions please don’t hesitate to contact our support chat at servebolt.com!