Using Cron Jobs
Use time scheduled cron jobs to execute long running operations in the background. They run at defined times, independent of visits to the web application.
Use cases¶
Database maintenance: say the web application cumulates data which needs to be transformed and/or wiped periodically. A Cron Job allows you to make sure the app/console db:cleanup
- or whatever - script executes hourly, daily, weekly or whenever your want.
Cache clearing: say the web application has a news site, which homepage must be rebuilt every ten minutes or so. With a Cron Job you can schedule a cleanup of the homepage.
Availabilty¶
Cron Jobs are only available for certain App plans. Please see the plans & pricing page for more.
Usage¶
You can configure your App's Cron Job in the Dashboard > {{app-name}} > Settings > Cron Jobs. To start a new Cron Job you'll need the set the following parameters:
Name¶
A unique name, so the job can be identified later on in the logs or statistics.
Command¶
The PHP command which shall be executed, eg app/console db:cleanup
or path/to/my-script.php
Interval¶
The interval at which you want to execute the job. The interval length is guaranteed, the exact time of execution is randomized. For example: an "every hour" interval will run once per hour with 60 minutes in between. However, it won't necessarily run at the 0th minute. It could run at the 11th minute or the 43th minute of every hour. All daily, weekly and monthly jobs run between 00:00 and 10:00 UTC. Weekly intervals will run on Monday.
Logging¶
All output generated by Cron Jobs can be accessed via log files and live logs.
Limits¶
- Crons on fortrabbit are managed in the Dashboard, not via SSH
- Only one cron per Universal App, not multiple
- Crons can only run every hour, not every minute
Alternatives¶
Universal Stack Apps have limited resources - shared with the PHP memory. Professional Apps come with the Worker Component, which offers dedicated resources — not shared. The Worker Component also allows multiple Cron Jobs per App and additionally Nonstop Jobs, which are persistently running background workers. Shorter intervals are also possible.