-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-services.sh
More file actions
46 lines (36 loc) · 1.1 KB
/
Copy pathcheck-services.sh
File metadata and controls
46 lines (36 loc) · 1.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
#!/bin/sh
# Create logs directory
logs="/srv/logs"
mkdir -p $logs
# System time variables (DO NOT CHANGE)
fulldate=$(date +"%c")
# Check apache status
ps auxw | grep /usr/sbin/apache2 | grep -v grep > /dev/null
if [ $? != 0 ]
then
/etc/init.d/apache2 restart > /dev/null
echo "[apache2] service is down: $fulldate" >> $logs/services-status.log
fi
# Check docker services
ps auxw | grep /usr/bin/docker | grep -v grep > /dev/null
if [ $? != 0 ]
then
/etc/init.d/docker restart > /dev/null
echo "[docker] service is down: $fulldate" >> $logs/services-status.log
fi
# Check nginx status
ps auxw | grep /usr/sbin/nginx | grep -v grep > /dev/null
if [ $? != 0 ]
then
/etc/init.d/nginx restart > /dev/null
echo "[nginx] service is down: $fulldate" >> $logs/services-status.log
fi
# Check mysql status
ps auxw | grep /usr/sbin/mysqld | grep -v grep > /dev/null
if [ $? != 0 ]
then
/etc/init.d/mysql restart > /dev/null
echo "[mysql] service is down: $fulldate" >> $logs/services-status.log
fi
# Wake up Docker (sometime it auto went idle)
/usr/bin/docker ps -a > /dev/null