Running a Cron Job on Easypanel
Run recurring tasks on Easypanel with scheduled scripts, a cron container, or an external scheduler.
A cron job runs a command on a schedule, such as clearing caches every hour or sending a report every morning. Easypanel can run scheduled commands inside your services, so most cron jobs need no extra containers or outside services.
Choose the approach that fits the task:
| Approach | Use it when |
|---|---|
| Scheduled script | The command needs the App's code and environment. This is the default. |
| Box and WordPress scripts | The service is a Box or WordPress service. |
| Cron container | You need many jobs, a crontab file, or jobs isolated from the web App. |
| External scheduler | The job is an HTTP request to your application. |
Scheduled script in an App service
-
Open the App service and select the Scripts tab.
-
Select Add Script.
-
Enter a Name and the command in Script, for example:
php artisan schedule:run -
Select a preset in Presets, or enter a cron expression in Schedule. For example,
*/5 * * * *runs every five minutes. Use crontab.guru to check an expression. -
Select Create.
Easypanel runs the script inside the running App container, with the same environment variables and files as the application. Each run appears as a system action on the Actions page, with its output.
Keep these points in mind:
- Cron schedules follow the server's time.
- Runs are skipped while the service is stopped.
- With several replicas, each run uses one container, not every replica.
- Runs are not queued. If a run takes longer than the interval, the next one starts anyway, so make the script safe to run more than once and at the same time.
See App scripts for how scripts run.
Box and WordPress services
Box and WordPress services have their own scripts with a cron schedule, an enabled switch, and a webhook URL. See Box scripts and WordPress scripts.
Cron container
For many jobs, or jobs you keep in a crontab file, run a cron daemon in a separate App service built from the same source. Keeping it apart from the web App means a slow or failing job does not affect requests, and each job runs once however many replicas the web App has.
For an Alpine-based image, add the crontab and start crond in the foreground:
RUN echo '*/5 * * * * /app/scripts/cleanup.sh' >> /etc/crontabs/root
CMD ["/usr/sbin/crond", "-f"]Give the cron App the same environment variables as the web App. crond does
not pass the container's environment to jobs by default, so load the variables
in the job script when it needs them.
External scheduler
When a job is an HTTP endpoint in your application, an external scheduler such as cron-job.org can call it on a schedule. Protect the endpoint with a secret token so that only the scheduler can trigger it.