Cloudways comes with an easy tool to create basic cronjobs, but what if we want to run more advanced cronjobs? Or, execute WordPress cronjobs via wp-cli?
Let’s dive into the setup on Cloudways!
Managing your application
Go to your application settings, and click on Cron Job Management.
You’ll see two tabs: Basic and Advanced, select the advanced tab.
You can now enter manual cronjobs.
The one I entered (the text below is a bit different from the screenshot) is:
*/10 * * * * /usr/local/bin/wp cron event run --due-now --path=/home/master/applications/{application_id}/public_html/ >> /home/master/logs/cron.log 2>&1
This translated to: Run the wp-cli comment “cron event run” every 10 minutes for this application and log the output to ~/logs/cron.log. (make sure to create this file first)
How to disable WordPress’ native cronjobs that execute on page load?
Add this to your wp-config.php file: define('DISABLE_WP_CRON', true);
How to time these cronjobs?
Honestly – every time I create a cronjob, I get my configuration from: https://crontab.guru/examples.html
This beautiful tool makes cronjobs so much easier!
Where does /usr/local/bin/wp
come from?
/usr/local/bin/wp
is where the wp-cli tool lives, you can find that path by entering which wp
in your terminal when connected via SSH.
Where do I find my application ID?
Your application ID is the same as your application username. You’ll find it in Access Details.
How do I create the cron.log file?
Connect to your server using SSH, and then run:
touch ~/logs/cron.log
Ed says
How often/many times an hr can you run a Cron with cloudways? For example Dreamhost let you do only 12 per hr
Marinus Klasen says
Up to a minute, and with some creativity, even up to seconds!