-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathrm-var-log-unwanted-danger
executable file
·64 lines (59 loc) · 1.56 KB
/
rm-var-log-unwanted-danger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
set -euf -o pipefail
##
# Remove /var/log files that we don't want.
#
# We use this to clean up drive space.
#
# Remove log rotation files:
#
# * Compressed files: these end in .bz2, .bzip, .gz, .tgz, .zip.
# * Sequence files: these end in .1, .2, .3, etc.
#
# Remove Unix system upgrade logs:
#
# * dist-upgrade/*
# * unattended-upgrades/unattended-upgrades-dpkg_*.log
#
# Remove specific programs' logs:
#
# * nagios3/archives/*
# * samba/log*
#
# Remove macOS logs:
#
# * asl/Logs/*
# * DiagnosticMessages/*.asl
# * powermanagement/*.asl
#
# Compatibility:
#
# * We prefer to be more compatible rather than system-specific.
#
# * To delete files, we prefer `-exec rm` vs. `-delete`.
# The former is more compatible, the latter is faster.
#
# * To regex, we prefer patterns to be basic vs. extended.
# The former is more compatible, the latter is more modern.
#
# Tracking:
#
# * Command: rm-log-files-danger
# * Version: 1.5.0
# * Created: 2013-12-09
# * Updated: 2017-08-29
# * License: GPL
# * Contact: Joel Parker Henderson ([email protected])
##
dir=/var/log
find $dir \( -name "*.bz2" -o -name "*.bzip" -o -name "*.gz" -o -name "*.tgz" -o -name "*.zip" -o -regex ".*\.[0123456789][0123456789]*" \) -exec rm {} \;
## Unix system upgrades
rm -rf $dir/dist-upgrade/*
rm -rf $dir/unattended-upgrades/unattended-upgrades-dpkg_*.log
## Specific programes
rm -rf $dir/log/samba/log*
rm -rf $dir/log/nagios3/archives/*
## macOS
rm -rf $dir/asl/Logs/*
rm -rf $dir/DiagnosticMessages/*.asl
rm -rf $dir/powermanagement/*.asl