Help / Websites and files

Cron jobs

Run a script automatically, for example every 15 minutes or every night.

A cron job runs a command on a schedule, as your own account. Many apps need one – for example the Laravel scheduler, WooCommerce tasks or a nightly cleanup.

Add a cron job

  1. On the Cron jobs page, fill in Schedule, Command and an optional Description.
  2. Choose Add cron job.

Untick Enabled to pause a cron job without deleting it.

The schedule

The schedule has five fields: minute, hour, day of month, month and weekday (0 = Sunday).

Schedule Runs
*/15 * * * * Every 15 minutes
0 * * * * Every hour, on the hour
30 2 * * * Every night at 02:30
0 7 * * 1 Mondays at 07:00
0 0 1 * * The first day of each month at midnight
@daily Once a day at midnight (also @hourly, @weekly, @monthly)

Times are in Danish time.

The command

Use the full PHP version in the command, so it matches your website:

php8.5 ~/example.dk/artisan schedule:run

Other examples:

php8.5 ~/example.dk/public/wp-cron.php
curl -fsS https://example.dk/cron.php

~ is your home folder. Cron jobs do not send e-mail. To keep the output, write it to a log file:

php8.5 ~/example.dk/cron.php >> ~/logs/cron.log 2>&1

A % in the command has a special meaning to cron. Write \% instead, for example in date +\%F.

WordPress

WordPress runs its scheduled tasks when someone visits the site. On a quiet site, or for exact timing, add define('DISABLE_WP_CRON', true); to wp-config.php and a cron job that runs wp-cron.php every 5 or 15 minutes, as in the example above.

Still need help?

Write to support@ge4.dk. Tell us your domain name and what you were doing, and include any error message. Never send passwords.