Introduction
On occasion you may find need to reset a domains's bandwidth to 0 for a given month before that month has rolled over. The instructions provided here will allow you to reset a specific domain to 0 for the month.
Procedure
First, copy the file at /var/cpanel/bandwidth/cpaneluser.sqlite
aside :
cp -avp /var/cpanel/bandwidth/cpaneluser.sqlite{,.bak}
This allows you to restore to the original usage should the need to do so arise.
Next, you will need to obtain the ID for the domain, to be used in further commands. To get the domain ID run the following command. This should return a single result:
[root@test ~]# /usr/local/cpanel/3rdparty/bin/sqlite3 /var/cpanel/bandwidth/cpaneluser.sqlite "SELECT id FROM domains WHERE name='domain.tld'"
2
[root@test ~]#
Using that ID you can then set the bandwidth for that domain to 0 (or any other value) using the following query:
[root@test ~]# /usr/local/cpanel/3rdparty/bin/sqlite3 /var/cpanel/bandwidth/cpaneluser.sqlite "UPDATE bandwidth_daily SET bytes='0' WHERE domain_id = '2';SELECT * FROM bandwidth_daily"
2|http|1605160800|0
[root@test ~]#
After running the noted query you would then need to run the command /usr/local/cpanel/scripts/rebuild_bandwidthdb_root_cache
. This will process bandwidth for every user within the server and not just the user you wish to manage:
[root@test ~]# /scripts/rebuild_bandwidthdb_root_cache
Rebuilding bandwidth cache for this system’s 1 cPanel user(s):
cpaneluser … Done!
[root@test ~]#
Once completed you should have a new SQLite file for the user along with the old file:
[root@test ~]# ls -la /var/cpanel/bandwidth/
total 180
drwx--x--x 2 root wheel 52 Nov 27 03:40 .
drwx--x--x 103 root root 8192 Nov 27 03:43 ..
-rw-r----- 1 root domain 86016 Nov 27 03:40 cpaneluser.sqlite
-rw-r----- 1 root domain 86016 Nov 27 03:37 cpaneluser.sqlite.bak
[root@test ~]#
and the interface should show 0 usage for the specified domain.