Forked from Red-Eyed/1. kill_vlc_on_resume.service
Last active
June 20, 2024 19:11
-
-
Save rubo77/2fe1fef2ff7f5bdd60a88a835f0c5573 to your computer and use it in GitHub Desktop.
truncate syslog after suspend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=deletes all but the last 1000 lines of syslog due to possible logging spam by VLC | |
[Service] | |
Type=oneshot | |
ExecStart=-/usr/local/sbin/truncate_syslog.sh | |
TimeoutSec=0 | |
StandardOutput=syslog | |
After=suspend.target | |
[Install] | |
WantedBy=multi-user.target sleep.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# save in /usr/local/sbin/truncate_syslog.sh | |
# deletes all but the last 1000 lines in syslog and vacuums journalctl down to 50 MB | |
LINES=1000 | |
tail -n $LINES /var/log/syslog > /tmp/tmpfile | |
cat /tmp/tmpfile > /var/log/syslog | |
rm /tmp/tmpfile | |
service syslog restart | |
journalctl --vacuum-size=50M | |
logger syslog "emptied and service restarted; journalctl vacuumed down to 50 MB" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo cp truncate_syslog_after_resume.service /etc/systemd/system/ | |
sudo systemctl enable truncate_syslog_after_resume.service --now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just added this after VLC spamming gbs into my syslog.
thanks for the help, @rubo77