Cron is a powerful tool that automates scheduled tasks at specific intervals. It's like having a virtual assistant for your website, performing routine jobs without you needing to lift a finger. For example, Cron can automatically back up important files every three hours, check for updates, or even publish new content on your WordPress site.
By default, WordPress doesn't use Cron for scheduling tasks, but you can set it up in two easy methods
Method 1: Using cPanel
- Log in to cPanel.
- In the cPanel home screen's Advanced section, click on Cron.
- Under Cron Email, enter your email address to receive notifications, then click Update Email. You'll get an email every time the cron job runs.
- If you don't want email notifications, you can add
>/dev/null 2>&1
to the command to redirect all output to /dev/null.
- If you don't want email notifications, you can add
- Under Add New Cron Job, choose "Twice an hour" from the Common Settings dropdown
- WordPress cron jobs should run every 30 minutes.
- In the Command text box, type:
cd ${HOME}/public_html; /usr/local/bin/php -q wp-cron.php
- Click Add New Cron Job, and your new cron settings will take effect immediately.
Method 2: Using the Command Line
- Log in to your account using SSH.
- At the command prompt, type:
crontab -e
- Type 'o' to enter editing mode and start a new line.
- Enter the following line, replacing 'username' with your A2 Hosting account username:
* * * * * cd ${HOME}/public_html; /usr/local/bin/php -q wp-cron.php
- If you installed WordPress in a different directory, adjust the 'cd' command accordingly.
- Press Esc, type ':wq', and press Enter. Your new cron job settings will take effect immediately.
Comments
0 comments
Please sign in to leave a comment.