virtualMachinewordpress-pro

Disable the WordPress cron script

NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

The wp-cron.php script will run once a user visits your site. If you get a lot of traffic, this could be a problem. This cron task is really necessary when you make updates in the blog. You can move this cron script to a system cron task to help lower resource usage on the server.

Approach A: Bitnami installations using system packages

Disable the wp-cron.php script in the /opt/bitnami/wordpress/wp-config.php file. The location is important - add the line below just before the database settings:

define('DISABLE_WP_CRON', true);

Then, add the cron task to the system. For example, this cron task will run the wp-cron.php process every hour. You can add it using the following command:

$ sudo crontab -e
0 * * * * su daemon -s /bin/sh -c "cd /opt/bitnami/wordpress; /opt/bitnami/php/bin/php -q wp-cron.php"

Approach B: Self-contained Bitnami installations

Disable the wp-cron.php script in the /opt/bitnami/apps/wordpress/htdocs/wp-config.php file. The location is important - add the line below just before the database settings:

define('DISABLE_WP_CRON', true);

Then, add the cron task to the system. For example, this cron task will run the wp-cron.php process every hour. You can add it using the following command:

$ sudo crontab -e
0 * * * * su daemon -s /bin/sh -c "cd /opt/bitnami/apps/wordpress/htdocs/; /opt/bitnami/php/bin/php -q wp-cron.php"
Last modification May 5, 2021