How to Automatically Update CyberPanel Disk Usage Every Minute: A Step-by-Step Guide
- 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:
Make sure the cron service is active and running:
bashCopy codesystemctl restart crond
Check cron service status:
bashCopy codesystemctl status crond
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
After a few minutes, check the CyberPanel logs:
bashCopy codetail -f /usr/local/CyberCP/debug.log
Look for any errors related to disk usage.
- 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:
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
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
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
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.
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.
If restarting the cron service doesn’t work, a server reboot might help:
bashCopy codereboot
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.
- Log in to CyberPanel Dashboard.
- Navigate to Websites > Manage Website > Disk Usage.
- Confirm that the disk usage is updating every minute.
