🛠️ Step 1: Edit the Cron Job File
- Open the cron job editor:bashCopy code
crontab -e - Add the following line to run the disk usage update every minute:bashCopy code
* * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py CalculateAndUpdateDiskUsage > /dev/null 2>&1 - Add this second line to check disk usage every minute:bashCopy code
* * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py checkDiskUsage > /dev/null 2>&1 - Save and exit:
- Nano:
Ctrl + O, thenCtrl + X - Vim:
:wq
- Nano:
🛠️ Step 2: Restart Cron Service
Make sure the cron service is active and running:
bashCopy codesystemctl restart crond
Check cron service status:
bashCopy codesystemctl status crond
🛠️ Step 3: Verify Cron Jobs are Active
List all active cron jobs to verify:
bashCopy codecrontab -l
You should see:
javascriptCopy code* * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py CalculateAndUpdateDiskUsage > /dev/null 2>&1
* * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py checkDiskUsage > /dev/null 2>&1
🛠️ Step 4: Monitor Logs for Errors
After a few minutes, check the CyberPanel logs:
bashCopy codetail -f /usr/local/CyberCP/debug.log
Look for any errors related to disk usage.
🛡️ Important Notes:
- Running the script every minute can slightly increase CPU and disk usage. Monitor server performance using:bashCopy code
top - If you notice server slowdowns, consider reducing the frequency to every 5 minutes:bashCopy code
*/5 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py
If systemctl restart crond is not working, it could mean that your server is not using crond or the service is named differently. Follow these steps to troubleshoot and resolve the issue:
🛠️ 1. Check if Cron is Installed
Run the following command to see if cron is installed:
bashCopy codecrontab -l
If it displays your cron jobs, cron is installed. If not, install it:
- For CentOS/RHEL:bashCopy code
yum install cronie -y - For Debian/Ubuntu:bashCopy code
apt install cron -y
🛠️ 2. Check the Cron Service Name
The cron service might be named differently depending on your OS:
- On CentOS/RHEL:bashCopy code
systemctl status crond - On Debian/Ubuntu:bashCopy code
systemctl status cron
If the service is cron instead of crond, restart it:
bashCopy codesystemctl restart cron
🛠️ 3. Enable and Start Cron Manually
If the service is stopped or disabled, enable and start it:
bashCopy codesystemctl enable crond
systemctl start crond
Or, if your system uses cron instead:
bashCopy codesystemctl enable cron
systemctl start cron
🛠️ 4. Verify Cron Service is Running
Check if the cron service is active:
bashCopy codesystemctl status crond
or
bashCopy codesystemctl status cron
If it shows active (running), your cron service is running fine.
🛠️ 5. Verify Cron Execution Manually
To ensure your cron job is working:
- Add a test cron job:bashCopy code
crontab -e - Add the following line:bashCopy code
* * * * * echo "Cron is working" >> /tmp/cron-test.log - After 2 minutes, check if the log is created:bashCopy code
cat /tmp/cron-test.log
If you see Cron is working, your cron setup is fine.
🛠️ 6. Restart the Server (if all else fails)
If restarting the cron service doesn’t work, a server reboot might help:
bashCopy codereboot
✅ Final Verification
After restarting the cron service or server:
- Verify the cron jobs:bashCopy code
crontab -l - Check the CyberPanel disk usage cron jobs:bashCopy code
tail -f /usr/local/CyberCP/debug.log - Monitor disk usage from the CyberPanel dashboard.