-
Notifications
You must be signed in to change notification settings - Fork 0
/
freeSpace.sh
73 lines (54 loc) · 1.22 KB
/
freeSpace.sh
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
65
66
67
68
69
70
71
72
73
#!/bin/bash
if [ $# -eq 1 ]
then
echo "Script is running ..."
else
echo "Provide password e.g. ./freeSpace.sh nvidia"
exit 1
fi
echo "Before cleaning"
df -h
echo "-------------------------------"
# clean journalctl logs
echo $1 | sudo -S journalctl --vacuum-size=50M 2>/dev/null
if [ $? -eq 0 ]
then
echo "Journalctl logs has been deleted OK"
else
echo "Journalctl logs has been deleted FAILED"
fi
# Delete cache
echo $1 | sudo -S rm -rf ~/.cache
if [ $? -eq 0 ]
then
echo ".cache has been deleted OK"
else
echo ".cache has been deleted FAILED"
fi
# Detele apt cache
echo $1 | sudo -S apt-get clean
if [ $? -eq 0 ]
then
echo "apt repository cache has been deleted OK"
else
echo "apt repository cache has been deleted FAILED"
fi
# Delete unnecesarry packages
echo $1 | sudo -S apt-get autoremove -y >/dev/null
if [ $? -eq 0 ]
then
echo "Removing unnecessary packages... OK"
else
echo "Removing unnecessary packages... FAILED"
fi
# Delete unnecesarry packages
echo $1 | sudo -S apt-get autoremove --purge -y > /dev/null
if [ $? -eq 0 ]
then
echo "Unnecessary packages have been deleted OK"
else
echo "Unnecessary packages has been deleted FAILED"
fi
echo "-------------------------------"
echo "After cleaning"
df -h