CRON Jobs allow you to schedule automatic tasks on your server, such as database backups, clearing cache, and running scripts.
Step 1: Create a CRON Job in cPanel
1️⃣ Log in to cPanel.
2️⃣ Go to Cron Jobs under the "Advanced" section.
3️⃣ In the Common Settings dropdown, choose how often the job runs (e.g., Once per day).
4️⃣ Enter the command to execute. Example:
php /home/username/public_html/cron_script.php
5️⃣ Click Add New Cron Job.
Step 2: CRON Job Examples
✅ Run a script every 5 minutes:
*/5 * * * * php /home/username/public_html/script.php
✅ Delete old logs every day at midnight:
0 0 * * * rm -rf /home/username/public_html/logs/*.log
✅ Backup the database every week:
0 0 * * 0 mysqldump -u user -p'password' database > /home/username/backups/db_backup.sql
✅ Check for WordPress updates every hour:
0 * * * * wp core update --path=/home/username/public_html/
Tip: Be careful with CRON jobs. A poorly written command can overload your server!