cPFence provides a powerful set of bulk tools that can be integrated into cronjobs for advanced server customizations and automated maintenance tasks. Below are the tools currently available for use in cronjobs:
Warning: The commands below will start immediately and apply to all websites in `/var/log/cpfenceav/wp-sites-list.txt` without asking for confirmation!
Don't forget that the sites list (/var/log/cpfenceav/wp-sites-list.txt) is updated automatically every day at 6:10 AM. You can stop this auto update from the configuration file if needed.
Bulk cPFence Tools that Support Cron Jobs
/opt/cpfence/app/wpautoshield/cpfautoshield Manually Trigger WP-AutoShield Security Measures.
/opt/cpfence/app/setup/cpfmain --generate-wp-sites-list Generate a list of WordPress sites.
/opt/cpfence/app/setup/cpfmain --vuln-export Export vulnerability reports in CSV format.
/opt/cpfence/app/setup/cpfmain --enable-wp-auto-updates -y Enable automatic WordPress updates.
/opt/cpfence/app/setup/cpfmain --disable-wp-auto-updates -y Disable automatic WordPress updates.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-cron -y Disable WordPress cron jobs in bulk.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-cron -y Enable WordPress cron jobs in bulk.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-file-edit -y Disable file editing in WordPress Admin.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-file-edit -y Enable file editing in WordPress Admin.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-pingback -y Disable WordPress pingbacks.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-pingback -y Enable WordPress pingbacks.
/opt/cpfence/app/setup/cpfmain --bulk-set-wp-secure-keys -y Set secure keys for all WordPress sites.
/opt/cpfence/app/setup/cpfmain --bulk-set-wp-permissions -y Apply secure file and directory permissions.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-hardening -y Enable WordPress hardening measures.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-hardening -y Disable WordPress hardening measures.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-xmlrpc -y Disable XML-RPC for WordPress sites.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-xmlrpc -y Enable XML-RPC for WordPress sites.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-limit-login -y Enable login limit protection.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-limit-login -y Disable login limit protection.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-idle-logout -y Enable idle logout protection.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-idle-logout -y Disable idle logout protection.
/opt/cpfence/app/setup/cpfmain --bulk-rename-wp-admin -y Rename the default WordPress admin username.
/opt/cpfence/app/setup/cpfmain --bulk-disable-xss-in-wp-posts -y Disable risky XSS code.
/opt/cpfence/app/setup/cpfmain --bulk-enable-xss-in-wp-posts -y Enable risky XSS code.
/opt/cpfence/app/setup/cpfmain --bulk-enable-wp-captcha -y Enable CAPTCHA for WordPress login forms.
/opt/cpfence/app/setup/cpfmain --bulk-disable-wp-captcha -y Disable CAPTCHA for WordPress login forms.
/opt/cpfence/app/setup/cpfmain --bulk-clear-litespeed-cache -y Clear LiteSpeed cache for all sites.
/opt/cpfence/app/setup/cpfmain --bulk-configure-ls-plugin -y Configure LiteSpeed Cache plugin.
/opt/cpfence/app/setup/cpfmain --bulk-install-ls-plugin -y Install the LiteSpeed plugin.
/opt/cpfence/app/setup/cpfmain --bulk-enable-ls-redis -y Enable Redis caching in LiteSpeed Cache plugin.
/opt/cpfence/app/setup/cpfmain --bulk-reset-ls-plugin -y Reset LiteSpeed plugin settings to defaults.
/opt/cpfence/app/setup/cpfmain --bulk-run-due-wp-cron -y Run all pending WordPress cron jobs immediately.
/opt/cpfence/app/setup/cpfmain --bulk-force-wp-core-files -y Restore WordPress core files to their defaults.
/opt/cpfence/app/setup/cpfmain --bulk-uninstall-cache-plugins -y Bulk uninstall all major cache plugins
/opt/cpfence/app/setup/cpfmain --bulk-uninstall-bl-plugins -y Bulk uninstall blacklisted plugins
/opt/cpfence/app/setup/cpfmain --bulk-install-plugin-bundle -y Bulk Install Plugin Bundle
How to Use These Tools in Cronjobs
To schedule any of these tools in a cronjob, follow these steps:
- Access your server via SSH.
- Edit the crontab file for the desired user:
crontab -e
- Add the desired command with the appropriate schedule. For example, to run a daily vulnerability export at 2 AM:
0 2 * * * /opt/cpfence/app/setup/cpfmain --vuln-export
- Save and exit the crontab file. The cronjob will now execute the specified command according to your schedule.
Best Practices
- Test commands manually before adding them to cronjobs to ensure they execute without errors.
- Review logs regularly to monitor the success or failure of cronjob executions.
- Keep your cPFence software updated to access the latest features and improvements.