Configuring the Cron Job

The application relies on the Laravel task scheduler for its periodic maintenance: purging expired listings, sending saved-search alerts, cleaning up cache files, taking backups, etc. Without the cron job below, these tasks don't run. Only the expired cache files are still cleaned up, over the visits, since LaraClassifier v19.1.5 and JobClass v19.1.5 (see Saturation of the cache directory).

How can I start the Scheduler?

Add the following Cron entry to your server. It must run every minute:

* * * * * cd /path/to/public_html && {PHP_BIN_PATH} artisan schedule:run >> /dev/null 2>&1

For shared hosting (when the cron tool only accepts a file path), use:

* * * * * {PHP_BIN_PATH} /path/to/public_html/utils/schedule-run.php >> /dev/null 2>&1

This Cron calls the Laravel command scheduler every minute. When schedule:run is executed, Laravel evaluates your scheduled tasks and runs the ones that are due. Running it every minute doesn't mean that the tasks run every minute: each task keeps its own frequency (see the table below).

  • {PHP_BIN_PATH}: the PHP CLI binary of your website's PHP version, e.g. /usr/bin/php8.3, /usr/bin/php, /usr/local/bin/php. Run which php over SSH to find it. On cPanel, it is often /usr/local/bin/php or /opt/cpanel/ea-php83/root/usr/bin/php.
  • /path/to/public_html/: replace this path with your real path (the folder that contains the artisan file).
  • On cPanel: go to Cron Jobs, select Once Per Minute (* * * * *) in Common Settings, and paste the command (without the leading * * * * *).
  • On Plesk: go to Scheduled Tasks, and add a task of type Run a command with the cron style * * * * *.
  • Don't run the cron job as root: the cache files it creates couldn't be deleted by the web server afterwards. Use the user that owns the website files.
  • Don't hesitate to ask your hosting provider for more information.

What does the Scheduler run?

Task Command Frequency Condition
Listings Purge (auto-archives and deletes listings after expiration) listings:purge Every hour Always
Saved-search alerts sending alerts:send-notifications Every hour Always
Expired password-reset tokens clean up auth:clear-resets Every 15 minutes Always
Cache Purge (deletes the expired and outdated cache files) expired-cache:purge Every day at 5:00 Always
Theme CSS cache clean up theme:prune-cache Every day at 5:15 Always
Full data cache clear cache:clear Every Sunday at 6:00 and 6:15 Unless disabled (see below)
Views cache clear view:clear Every Sunday at 6:00 Only when enabled (see below)
Backups backup:run / backup:clean As configured Admin panel → Settings → Backup
Queue worker ("poor man's queue") queue:scheduled-work As configured Database or Redis queue, and enabled under Admin panel → Settings → Optimization

The times are evaluated in the website's time zone. These options can be set in the /.env file:

  • CACHE_MANAGER_FORCE_CLEAN_UP=false: disables the weekly full data cache clear (not recommended). The daily Cache Purge still runs.
  • VIEW_CACHE_AUTO_CLEAN_UP=true: enables the weekly views cache clear (disabled by default).

NOTE: The former DISABLE_CACHE_AUTO_CLEAR variable is no longer used.

How can I check that the cron job works?

Over SSH, from the website's root folder:

  • php artisan schedule:list lists the scheduled tasks with their next due date.
  • php artisan schedule:run runs the tasks due now, exactly as the cron job does.
  • php artisan expired-cache:purge runs the Cache Purge immediately and reports what it deleted.

Without SSH access, temporarily replace >> /dev/null in the cron job with >> /path/to/public_html/storage/logs/cron.log, wait a few minutes, then check that this file is filled every minute. Revert the change once done.

How does the Listings Purge command work?

There are 2 cases to consider:

1. Regular Listings

Configure the options below under Admin panel → Settings → Cron:

  • Unactivated Listings Expiration: after this time (in days), the unactivated listings are deleted.
  • Activated Listings Expiration: after this time (in days), the activated listings are archived.
  • Archived Listings Expiration: after this time (in days), the archived listings are deleted.
  • Manually Archived Listings Expiration: after this time (in days), the manually archived listings are deleted.

In JobClass, these options are named Unactivated Ads Expiration, Activated Ads Expiration, etc.

2. Premium / Paid Listings

  • After the plan duration set under Admin panel → Plans → [EDIT] → Duration, the premium listings become regular listings.
    • The publication duration of an active free plan (i.e. a plan with 0 as price) replaces the Activated Listings Expiration setting for all free listings. When several plans apply to a listing (free plans, the author's subscription and the listing's promotion), the highest duration is used. See How Plan Limits Work.
    • For site owners that have installed the Offline Payment add-on, the listings pushed as premium (i.e. manual promotions from the admin panel) never expire. You need to un-feature them (i.e. remove the promotion manually) first.
  • Then, the Regular Listings rules (described in #1) are applied to clean up the website database.

Was this article helpful?

Thank you for your feedback!

Still need help? Create a support ticket

Create a Ticket