Cron Scheduler

Automate recurring tasks and scheduled maintenance in PteroCA.

Cron Job Schedule

The pteroca:cron:schedule command is a critical system command designed to execute other scheduled commands at defined intervals. It serves as a facade, running specific system maintenance commands that ensure the smooth operation of the panel. This command is intended to be added to a crontab (or a crontab alternative) to automate recurring tasks.

  • Command: pteroca:cron:schedule

  • Alias: app:cron-job-schedule (deprecated, removed in v1.0.0)

For detailed instructions on adding this command to your crontab, refer to the Crontab Configuration section in the documentation.

Examples

# Recommended (v0.6+)
docker exec pteroca_web_dev php bin/console pteroca:cron:schedule

# Deprecated (still works until v1.0.0)
docker exec pteroca_web_dev php bin/console app:cron-job-schedule

Scheduled Commands

Commands executed by the scheduler:

Every Minute

  • pteroca:server:suspend-unpaid - Suspends servers for users with unpaid balances

  • pteroca:plugin:cron:run - Executes due plugin cron tasks

Hourly

  • pteroca:system:cleanup-tokens - Deletes expired purchase tokens

  • pteroca:server:delete-inactive - Deletes inactive servers (if enabled)

Daily/As Configured

  • pteroca:system:cleanup-logs - Deletes old logs (if enabled)

Automating with Crontab

To ensure this command runs automatically, add it to your crontab (or an alternative scheduling system). For example, to run this command every minute, use the following crontab configuration:

Important: Make sure to update your crontab to use pteroca:cron:schedule before upgrading to v1.0.0!

Docker Environment

If you're running PteroCA in Docker, add the cron command to your host's crontab:

Or set up a cron container in your docker-compose.yml:

Setting Up Crontab

Step 1: Open Crontab Editor

Step 2: Add the Cron Entry

Add one of the following lines depending on your setup:

Standalone Installation:

Docker Installation:

Step 3: Save and Exit

The cron daemon will automatically pick up the new schedule.

Verifying Cron Setup

Check Crontab

Check System Logs

Test Manually

Troubleshooting

Cron Not Running

Check cron service:

Restart cron service:

Commands Not Executing

Check file permissions:

Make console executable:

Plugin Cron Tasks Not Running

List plugin cron tasks:

Check if plugins are enabled:

Manually run plugin cron tasks:

Best Practices

  1. Use absolute paths - Always use full paths to PHP and the console script

  2. Redirect output - Use >> /dev/null 2>&1 to suppress output

  3. Test first - Run commands manually before adding to crontab

  4. Monitor logs - Check system logs and PteroCA logs regularly

  5. Update commands - Switch to new pteroca:* namespace before v1.0.0

Last updated