To turn on a server-side cron job for WordPress, you can follow these steps:
- Disable Default WordPress Cron :
- Open your
wp-config.php
file located in your WordPress root directory. - Add the following line before the line that says “/* That’s all, stop editing! Happy blogging. */”:
define('DISABLE_WP_CRON', true);
- Save the
wp-config.php
file.
- Create a Cron Job :
- Access your server’s Cloudpanel.
- Navigate to the Cron Jobs section.
- Add a new cron job with the following command:
/usr/bin/php8.0 /home/yourdomain-beershop/htdocs/yourdomain.ch/script.php
- This command will execute the PHP script
script.php
using PHP version 8.0.
- Set the Frequency :
- Specify how often you want the cron job to run. You can set the frequency based on your specific needs, such as every minute, hourly, daily, etc.
By following these steps, you can effectively set up a server-side cron job for WordPress using the specified PHP script and PHP version.
Single Run Command
cd /home/USER/htdocs/SITE; wp cron event run --due-now >/dev/null 2>&1