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

Start Your 7-Day Free Trial

Start your SpinupWP journey today and spin up your first server within minutes.

Start Your Free Trial

No credit card required

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.

You are already logged in

It looks like you are already logged in to SpinupWP.

Please log out of this account to continue.

Registration Successful

Thanks for registering for a new
SpinupWP account.

Before getting started, could you verify your email address by clicking on the link we just emailed to you?

SpinupWP

Free Trial

Start Your 7-Day Free Trial

No credit card required. All features included.

By signing up to SpinupWP, you agree to our Terms and Conditions.
For privacy related information, view our Privacy Policy.