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 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 about crons and see some practical examples.
If you have written the command you want to add and you’d rather use a free tool 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 Kinsta’s support team to upload the job to the crontab for you.
Finally, paste the command at the end of the list.
Then close the file. When you close the file you will 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 simply open a support ticket and ask Kinsta’s support team to add the job to your site’s crontab.
Kinsta Policies on Server Crons
- Kinsta’s support of server crons 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 crons 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.
- 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 crons at the top of the file our maintenance scripts, staging system, or backup system may overwrite your custom server cron jobs.
If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans