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 can be defined, not multiple
  • The shortest time interval is once every hour, not every minute
  • Cron scripts can run for maximum 12 hours, then it will be killed
  • Each time the cron triggers, a new copy of the cron script is started
  • When 5 scripts are running at the same time, no more will start until another exits

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.

All articles

Craft CMS

Statamic

Install guides

Code access

Deployment

Git

SSH

SFTP

Troubleshooting

DNS

MySQL

TLS (SSL)

htaccess

Development

Teamwork

Platform

Billing

The Dashboard

Stacks

Tips & tricks

Quirks

Support

FAQ

Need individual help?
Learn about Company plans ›
Looking for an old article?
See the full list of articles ›
Found an error?
Contribute on GitHub ›