I have a WordPress website, where I added some custom cron jobs. I know wp-cron is not a real cron job, it runs when the page is loaded. But right now I don’t have much traffic so my cron job misses the schedules. So I want to set up a system-based cron job for my website. However, I’m not quite sure how to set it up. Could someone guide me on creating a system-based cron job for WordPress?
To set up a system-based cron job in WordPress, follow these simple steps:
- Open the wp-config.php file in a text editor.
- Add the following line before the
/* That's all, stop editing! Happy blogging. */
line.
define('DISABLE_WP_CRON', true);
- Log into your cPanel account.
- Open the “Cron Jobs” application in the “Advanced” section of cPanel.
- Add the following command
wget -q -O - http://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
Or
/usr/bin/php -q /path-to-your-wp-installation/wp-cron.php
- Replaced “example.com” with your domain name.