I have a customised linux version, kernel version is 4.1.15-klk
my platform architecture is armv7l GNU/Linux
I am trying to check if my process is running or not :
I tried this:
#!/bin/sh
service=myservice
if [ $(ps | grep -v grep | grep $service | wc -l) -gt 0 ]
then
echo "$service is running!!!"
else
echo "$service is not running!!!"
fi
but it is giving me "myservice is running!!!" whether it is running or not
I can't use pgrep since it is not available in my system
any ideas? thanks!
ps | grep -v grep | grep $service
? – John1024 Dec 22 '17 at 20:49ps | grep -v grep | grep $service
and when it is running it display the service information in one line – sabrina2020 Dec 22 '17 at 20:59if [ $(ps | grep -v grep | grep "$service" | tee ~/service.log | wc -l) -gt 0 ]
and then inspect~/service.log
to verify that what the output really is. – John1024 Dec 22 '17 at 21:12