Skip to content

Cron Jobs

ColibriPlus requires scheduled tasks (cron jobs) to run in the background for essential maintenance operations like database cleanup, temporary file removal, and other automated processes.

Since ColibriPlus is powered by Laravel, it uses Laravel's Task Scheduling system under the hood. This means any feature from the Laravel scheduling ecosystem is fully supported.

How It Works

Instead of creating multiple cron entries on your server, Laravel allows you to define all scheduled tasks within the application itself. You only need a single cron entry on your server that runs Laravel's scheduler every minute. The scheduler then determines which tasks need to run based on their defined schedule.

What Gets Scheduled

ColibriPlus uses cron jobs for the following background tasks:

  • Database cleanup - Removes expired sessions, old tokens, and stale records
  • Temporary file cleanup - Clears temporary uploads and cached files
  • Queue health monitoring - Ensures background jobs are processed correctly
  • Other maintenance tasks - Various housekeeping operations required by the application

Setup

To activate the scheduler, you need to add a single cron entry to your server. Open your server's crontab:

bash
crontab -e

Add the following line:

bash
* * * * * cd /path/to/your/colibriplus && php colibri schedule:run >> /dev/null 2>&1

Important

Replace /path/to/your/colibriplus with the actual path to your ColibriPlus installation directory.

This entry tells the system to run the Laravel scheduler every minute. The scheduler will then check if any tasks are due and execute them automatically.

Verifying the Setup

To confirm your scheduled tasks are registered and working, you can list all scheduled tasks:

bash
php colibri schedule:list

This command will display a table with all registered tasks, their frequency, and next run time.

You can also run the scheduler manually to verify everything works:

bash
php colibri schedule:run

Logging

By default, the cron output is discarded (>> /dev/null 2>&1). If you want to log the scheduler output for debugging purposes, you can redirect it to a log file:

bash
* * * * * cd /path/to/your/colibriplus && php colibri schedule:run >> /path/to/your/colibriplus/storage/logs/cron.log 2>&1

Check the log file for any errors:

bash
tail -f storage/logs/cron.log

Troubleshooting

Cron Not Running

  • Make sure the cron service is running on your server:
bash
sudo systemctl status cron
  • Verify your crontab entry is saved:
bash
crontab -l
  • Check that the path to your ColibriPlus installation is correct
  • Ensure php is accessible from the cron environment. If not, use the full path to PHP:
bash
* * * * * cd /path/to/your/colibriplus && /usr/bin/php colibri schedule:run >> /dev/null 2>&1

Permission Issues

Make sure the cron job runs under a user that has the correct permissions to access the ColibriPlus files. Typically this should be the same user that owns the application files (e.g., www-data).

bash
sudo crontab -u www-data -e

Official Documentation

For more details on task scheduling and advanced configuration, refer to the official Laravel Task Scheduling documentation.

Developed by Mansur Terla. www.terla.me