Marinus Klasen

Marinus Klasen

  • Development
  • Consultancy
  • Developer Resources
  • Blog
  • Contact

March 16, 2022

Managing cronjobs in Cloudways

Marinus Klasen

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

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

This site runs on Cloudways.
It's fast isn't it?
Cloudways offers high-quality, fast and affordable hosting.

Learn more

Need a hand? Post your project and hire me and other top notch developers on Codeable.

Hire me on Codeable

Comments

  1. Ed says

    November 16, 2022 at 8:44 am

    How often/many times an hr can you run a Cron with cloudways? For example Dreamhost let you do only 12 per hr

    Reply
    • Marinus Klasen says

      November 18, 2022 at 4:16 pm

      Up to a minute, and with some creativity, even up to seconds!

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ready to take action?

I'm looking forward to discuss your projects and goals!
Feel free to reach out using the contact details below.

Marinus Klasen

[email protected]
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Storing private data with SSH on WPEngine sitesDecember 15, 2022
  • Get the HTML content of a block edit page or post in WordPressNovember 30, 2022
  • Rename Coupon code text to Discount code in WoocommerceNovember 3, 2022
  • Background-size cover in mPDFOctober 22, 2022
  • WordPress.com SSH & duplicating a WordPress.com website locallyOctober 11, 2022

Copyright © 2023 · Marinus Klasen | Webdesign by Team Rood