aboutsummaryrefslogtreecommitdiffstats
path: root/main/atop/atop-bb-compat.patch
blob: ec46d242667d1b4b6ef80b3f323ddaafecb58b24 (plain)
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
diff --git a/atop.daily b/atop.daily
index e0d994f..8c0cfc0 100755
--- a/atop.daily
+++ b/atop.daily
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 CURDAY=`date +%Y%m%d`
 LOGPATH=/var/log/atop
 BINPATH=/usr/bin
@@ -7,11 +7,15 @@ INTERVAL=600		# interval 10 minutes
 
 # verify if atop still runs for daily logging
 #
-if [ -e $PIDFILE ] && ps -p `cat $PIDFILE` | grep 'atop$' > /dev/null
-then
-	kill -USR1 `cat $PIDFILE`	# take final sample
+pid=
+if [ -e $PIDFILE ]; then
+	pid=$(cat $PIDFILE)
+fi
+
+if [ -n "$pid" ] && [ -d /proc/$pid ]; then
+	kill -USR1 $pid	# take final sample
 	sleep 3
-	kill -TERM `cat $PIDFILE`
+	kill -TERM $pid
 	rm $PIDFILE
 	sleep 1
 fi