Operations

Running scans from the server cron

Scheduled scans use WP-Cron, which only runs when the site receives a request. For reliable monitoring, run the scan from the server cron. When no scan has completed for longer than expected, Keep It Peace shows “Scheduled scans may not be running.” on its screens.

With WP-CLI

0 3 * * * cd /path/to/wordpress && wp keep-it-peace scan --quiet

Settings → Tools shows this line with the path of your site. --quiet prints nothing unless something fails. On shared hosting, the CLI and the web server may use different PHP versions or php.ini files; Keep It Peace evaluates the PHP information recorded by the web server (for example when you open the admin screens).

Without WP-CLI

If WP-CLI is not available, call wp-cron.php instead (Settings → Tools shows the URL of your site):

*/15 * * * * curl -s https://example.com/wp-cron.php?doing_wp_cron > /dev/null

Example: Xserver

Add the commands in Server Panel → Cron settings. Use full paths. Plain wp may run with a different PHP version than your site, so run WP-CLI (/usr/bin/wp) with the PHP of your site (for example /usr/bin/php8.3, the version selected in the server panel).

WhenCommand
Every day (e.g. minute 0, hour 3)cd /home/<server ID>/<domain>/public_html && /usr/bin/php8.3 /usr/bin/wp keep-it-peace scan --quiet
Every 5 minutes (minute */5), when WP-Cron is disabledcd /home/<server ID>/<domain>/public_html && /usr/bin/php8.3 /usr/bin/wp cron event run --due-now --quiet

To get errors by e-mail while you set it up, enter an address in the cron result notification setting of the server panel.

Disabling WP-Cron

When you use a server cron, you can add this line to wp-config.php so that WP-Cron no longer runs on page views:

define( 'DISABLE_WP_CRON', true );

Keep It Peace’s daily maintenance (deleting old history and sending the weekly digest) and the scheduled scan are WP-Cron events. With DISABLE_WP_CRON, they run only when something runs WP-Cron, so also run wp cron event run --due-now (or call wp-cron.php) from the server cron, as in the Xserver example. The dashboard then shows “DISABLE_WP_CRON is set: make sure a server cron job runs.” as a reminder.