Kinsta’s container-based infrastructure means that every site runs in a private container with its own crontab. This means that at Kinsta, we allow our users to add real server cron jobs to each site container.
If you’d rather use the WordPress built-in cron system, please see our article on how to create and modify a WordPress cron job.
How to Write a Server Cron
A task added to crontab consists of two parts:
- A series of numbers and asterisks defining how frequently the cron should run.
- A command to be executed on the server.
When writing a cron, you’ll need to determine those two factors: the command that needs to be executed and how frequently it should be scheduled.
If you want to work out the crontab syntax yourself, the crontab documentation from The Open Group is a great place to learn and see some practical examples.
If you have written the command you want to add and you’d rather use a free tool to generate the full crontab syntax, there are a variety of online tools you can use to generate the full command in proper crontab syntax. Crontab Generator is one of our favorite tools that can be freely used for this purpose.
How to Add a Server Cron
Once you have the cron job ready to add to the container, you have two options:
- Add the job to the crontab yourself.
- Ask our Support team to upload the job to the crontab for you.
To upload the job yourself,
- Access your site container over SSH
- Run the following command:
- Select your text editor of choice (select nano if you’re unsure).
- Paste your cron command at the end of the file.
- Then close the file. You’ll see a message like this confirming that the crontab has been updated:
crontab: installing new crontab.
If you aren’t comfortable using SSH, you can open a new chat with our Support team and ask us to add the job to your site’s crontab.
Kinsta Policies on Server Cron Jobs
- Kinsta’s support of server cron jobs is limited to uploading the cron job exactly as you provide it to the container crontab or editing cron jobs as you direct. If you need assistance writing the command that will be executed by crontab, you will need to work with a qualified developer to write the cron job.
- The minimum cron job interval is 5 minutes. Please do not upload server cron jobs that will run more frequently than every 5 minutes. If you ask our Support team to add a cron that runs more frequently than every 5 minutes, we will suggest that the interval be increased to 5 minutes. If you need a cron to run more often, you’ll need a dedicated server to do so. On a dedicated server, you can run cron jobs every minute.
- Please do not edit or move the jobs at the top of the crontab. These jobs are added by our System Engineering team and must remain at the top of the file.
- Please add your custom server cron jobs to the bottom of the crontab file. If you add your custom server cron jobs at the top of the file, our maintenance scripts, staging system, or backup system may overwrite your custom server cron jobs.