summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2017-04-28 13:07:47 -0500
committerKyle K <kylek389@gmail.com>2017-04-28 13:07:47 -0500
commitd51fdde75c7a1f2c6cc6c043105162b831585c1c (patch)
tree0cf6724ffad6136dbb6cc3ba3932e2a48660a7dd
parenta5bc331bbfa66915b3a83ad389cacdaa1891d215 (diff)
downloadconfigs-d51fdde75c7a1f2c6cc6c043105162b831585c1c.tar.gz
configs-d51fdde75c7a1f2c6cc6c043105162b831585c1c.tar.bz2
configs-d51fdde75c7a1f2c6cc6c043105162b831585c1c.zip
misc unix cleaning script
-rwxr-xr-xclean-logs.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/clean-logs.sh b/clean-logs.sh
new file mode 100755
index 0000000..0ea4956
--- /dev/null
+++ b/clean-logs.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# clean traditional logs etc.
+find /var/log/ -type f -name "*.gz" -exec rm -f {} \;
+find /var/log/ -type f -name "*.1" -exec rm -f {} \;
+find /var/log/ -type f -name "*.old" -exec rm -f {} \;
+
+# clean systemd's journal
+if [[ -d /var/log/journal ]]; then
+ systemctl stop systemd-journald
+ journal_dirs=$(find /var/log/journal/ -maxdepth 1 -type d -name "a*")
+ for j in $journal_dirs; do
+ echo "removing ${j}"
+ rm -rf $j
+ done
+ systemctl start systemd-journald
+fi
+
+# clean atop logs
+if [[ -d /var/log/atop ]]; then
+ systemctl stop atop
+ rm -f /var/log/atop/*
+ systemctl start atop
+fi
+
+# clean samba logs
+if [[ -d /var/log/samba ]]; then
+ rm -rf /var/log/samba/*
+fi
+
+# at last truncate all *.log
+find /var/log/ -name "*.log" -exec truncate -s 0 {} \;
+
+exit 0