[GH-ISSUE #3462] traffic reset regularly #2356

Closed
opened 2026-10-31 20:24:57 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @907739769 on GitHub (Sep 13, 2025).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/3462

I set a traffic limit, but I want to reset the traffic limit regularly, such as on the 15th of every month, to reset all inbound and client traffic.

Describe the solution you'd like

I set a traffic limit, but I want to reset the traffic limit regularly, such as on the 15th of every month, to reset all inbound and client traffic.

Describe alternatives you've considered

No response

Checklist

  • This feature report is written entirely in English.
Originally created by @907739769 on GitHub (Sep 13, 2025). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/3462 ### Is your feature request related to a problem? I set a traffic limit, but I want to reset the traffic limit regularly, such as on the 15th of every month, to reset all inbound and client traffic. ### Describe the solution you'd like I set a traffic limit, but I want to reset the traffic limit regularly, such as on the 15th of every month, to reset all inbound and client traffic. ### Describe alternatives you've considered _No response_ ### Checklist - [x] This feature report is written entirely in English.
bsakaguchi 2026-10-31 20:24:57 +07:00
Author
Owner

@TLCFEM commented on GitHub (Sep 18, 2025):

Before it is implemented, what you can do is the following.

Since it uses a sqlite database to store everything, it is possible to directly update the corresponding table in the database.

The following python code snippet will reset all traffic to zero.

import sqlite3
import sys

if __name__ == "__main__":
    con = sqlite3.connect(sys.argv[1])
    con.cursor().execute("UPDATE client_traffics SET up = 0, down = 0")
    con.commit()
    con.close()

Save it as, for example reset_traffic.py, then you can call it with the following.

python reset_traffic.py /path/to/x-ui.db

Of course you need to find the correct path of x-ui.db file, probably on the host, or in the docker container, depending on how it is deployed.

To periodically perform the reset, just create a cron job.

<!-- gh-comment-id:3305253277 --> @TLCFEM commented on GitHub (Sep 18, 2025): Before it is implemented, what you can do is the following. Since it uses a sqlite database to store everything, it is possible to directly update the corresponding table in the database. The following python code snippet will reset all traffic to zero. ```py import sqlite3 import sys if __name__ == "__main__": con = sqlite3.connect(sys.argv[1]) con.cursor().execute("UPDATE client_traffics SET up = 0, down = 0") con.commit() con.close() ``` Save it as, for example `reset_traffic.py`, then you can call it with the following. ```bash python reset_traffic.py /path/to/x-ui.db ``` Of course you need to find the correct path of `x-ui.db` file, probably on the host, or in the docker container, depending on how it is deployed. To periodically perform the reset, just create a cron job.
Author
Owner

@907739769 commented on GitHub (Sep 19, 2025):

Before it is implemented, what you can do is the following.

Since it uses a sqlite database to store everything, it is possible to directly update the corresponding table in the database.

The following python code snippet will reset all traffic to zero.

import sqlite3
import sys

if name == "main":
con = sqlite3.connect(sys.argv[1])
con.cursor().execute("UPDATE client_traffics SET up = 0, down = 0")
con.commit()
con.close()
Save it as, for example reset_traffic.py, then you can call it with the following.

python reset_traffic.py /path/to/x-ui.db
Of course you need to find the correct path of x-ui.db file, probably on the host, or in the docker container, depending on how it is deployed.

To periodically perform the reset, just create a cron job.

I'm now a scheduled task calling API interface. /panel/inbound/resetAllClientTraffics/-1 /panel/inbound/resetAllTraffics

<!-- gh-comment-id:3310273976 --> @907739769 commented on GitHub (Sep 19, 2025): > Before it is implemented, what you can do is the following. > > Since it uses a sqlite database to store everything, it is possible to directly update the corresponding table in the database. > > The following python code snippet will reset all traffic to zero. > > import sqlite3 > import sys > > if __name__ == "__main__": > con = sqlite3.connect(sys.argv[1]) > con.cursor().execute("UPDATE client_traffics SET up = 0, down = 0") > con.commit() > con.close() > Save it as, for example `reset_traffic.py`, then you can call it with the following. > > python reset_traffic.py /path/to/x-ui.db > Of course you need to find the correct path of `x-ui.db` file, probably on the host, or in the docker container, depending on how it is deployed. > > To periodically perform the reset, just create a cron job. I'm now a scheduled task calling API interface. `/panel/inbound/resetAllClientTraffics/-1` `/panel/inbound/resetAllTraffics`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#2356
No description provided.