-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaintain.sh
More file actions
73 lines (73 loc) · 2.1 KB
/
maintain.sh
File metadata and controls
73 lines (73 loc) · 2.1 KB
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/sh
# File: maintain.sh
# Auth: Michael Cummings, Library Systems
# Watson Library, Metropolitan Museum of Art
#
# Desk: Routine maintenance tasks -- run every week
#
#---------------------------
# Update packages
#---------------------------
sudo apt-get upgrade
#
#-------------------------------------
# Monitor , and create free disk space
#-------------------------------------
df -h /dev/xvda1
# example result
# Filesystem Size Used Avail Use% Mounted on
# /dev/xvda1 7.7G 4.6G 3.2G 59% /
#
sudo apt-get clean
sudo apt-get autoremove
#-------------------------------------------------
# Remove all but the last 50 lines of this logfile
#-------------------------------------------------
tail -50 /var/www/html/clancy/clancyAPIrun.txt > tempfile
mv tempfile /var/www/html/clancy/clancyAPIrun.txt
#
#---------------------------------------------------
# Routinely delete mail manually with the following:
#---------------------------------------------------
echo 'please delete old mail messages'
# mail
# (a numbered list will display)
# delete 1-n
# or
# d1-n
# (where n is the highest number)
# q
#
#-----------------------------
# monitor the apache error log
#-----------------------------
# this command shows logged errors for the web server
# if a particular ipaddress appears to be probing php commands
# you should add the ipaddress to blocked addresses.
cat /var/log/apache2/error.log
# to block ip addresses NNN.NNN.NNN.NNN
# sudo iptables -A INPUT -s NNN.NNN.NNN.NNN -j DROP
# to see blocked ip addresses
# sudo iptables -S
#
echo 'Please add suspcious ip of suspicious commands to iptable blocked'
#--------------------------------
# maintain journal files
#--------------------------------
sudo journalctl --vacuum-time=2days
#
echo
echo
#-----------------------------------
# monitor virtual memory stats
#-----------------------------------
# vmstat shows virtual memory statistics. look for free memory
vmstat
#
# free also shows memory statistics
free
#
# df -h shows disk statistics
#
# top shows process and memory use
#