Control Web Panel
WebPanel => How to => Topic started by: Starburst on December 07, 2025, 10:56:31 PM
-
Anyone know how to clear the Alerts & Notifications completely out from the CLI?
There is a scripts to add alerts, but didn't see any for read and/or clear.
Thanks
-
I poked around one day but didn't come up with any solid answers.
-
The below is the json file you'd need to alter to be an empty array, it houses the notifications. It can't be empty though, must always contain an empty array eg: [] - or the GUI will crash. There are JSON terminal tools like js & sponge etc that can edit the file if your brave. Alernatively you can execute a python script to overwrite the file contents with empty array
/usr/local/cwpsrv/htdocs/resources/admin/include/libs/notifications/notifications.json
-
A python solution is to create the below file called clear_notices.py in /usr/local/cwpsrv/htdocs/resources/admin/include/libs/notifications (when executed it simply replaces the notification data which is stored in an array with an empty array)
import json
filename = 'notifications.json'
clear_notifications = []
try:
with open(filename, 'w') as json_file:
json.dump(clear_notifications, json_file, indent=4)
print(f"Successfully edited '{filename}' to be an empty array [].")
except FileNotFoundError:
print(f"Error: The file '{filename}' was not found.")
except Exception as e:
print(f"An error occurred: {e}")
You can then run in via the terminal
cd /usr/local/cwpsrv/htdocs/resources/admin/include/libs/notifications
python3 clear_notices.py
You can also set up up cron job to run it as often as you wish
-
Bravo! But if I'm not missing something, wouldn't it be easiest to empty the notifications like so:
echo '[]' > /usr/local/cwpsrv/htdocs/resources/admin/include/libs/notifications/notifications.json
-
Yup, works too!
-
And here, CWP actual said it could not be done... ???
-
Bravo! But if I'm not missing something, wouldn't it be easiest to empty the notifications like so:
echo '[]' > /usr/local/cwpsrv/htdocs/resources/admin/include/libs/notifications/notifications.json
@overseer I like it, simple and quick.
-
Bravo! But if I'm not missing something, wouldn't it be easiest to empty the notifications like so:
echo '[]' > /usr/local/cwpsrv/htdocs/resources/admin/include/libs/notifications/notifications.json
Excellent ! Simple and effective solution :)