How to Add Cron Jobs

A UI to configure cron jobs right from the SpinupWP dashboard is on the roadmap, but if you are looking to add cron jobs for your sites right now, then here are the manual steps you need to take.

Non-Root Cron Job

If the scheduled command doesn’t need to be run as the root user, it should be set up to run as a site user:

  1. First, SSH to your server as the site user for the site you want to add the cron job to
  2. Enter the command crontab -e to bring up the cron job editor
  3. If this is the first time you have done this, the command will ask you to ‘Select an editor’. Nano is the easiest editor, so enter ‘1’ to select it.
  4. Add your cron command on a new line
  5. Save the crontab file and exit. With Nano, this is Ctrl/Cmd + X, then Y.

If you need help generating your cron command and configuring the syntax for the schedule, then this crontab generator can help.

For example, this command runs a bash script in the root of a site every 12 hours and doesn’t save or send output:

* */12 * * * cd /sites/mysite.com/files/; sh example-script.sh >/dev/null 2>&1

Root Cron Job

If the scheduled command requires root permissions then you will need to add the crontab line to the root user. You will need to have already created a sudo user on the server and recorded the password somewhere.

  1. SSH to your server as the sudo user
  2. Enter the command sudo crontab -u root -e
  3. You will be asked for your sudo user password, enter it now
  4. If this is the first time you have done this, the command will ask you to ‘Select an editor’. Nano is the easiest editor, so enter ‘1’ to select it.
  5. Add your cron command on a new line
  6. Save the crontab file and exit

Ready to give SpinupWP a try?

Not sure if SpinupWP is the right fit for you? Send us an email at sudo@spinupwp.com and we’ll give you our no-BS opinion.

Subscribe to get the latest news, updates and optimizations in performance and security.

Thanks for subscribing 👍

To receive awesome stuff, you'll need to head to your inbox and click on the verification link we sent you.
Make sure to check your "spam" folder or your "promotions" tab (if you have Gmail).
If you're still having trouble, then messages us at sudo@spinupwp.com.