I have written an executable shell script which is meant to close the epiphany browser on my raspberry pi if the browser usage is 0. If i run the following command i see values above 0 if the browser in use and if its not then its 0:
top -b -n 1 | grep epiphany-browse | awk '{ totuse = totuse + $9 } END { print totuse }'
but then put it in a script it does not kill the browser process:
while true
sleep 60s
do
if [ top -b -n 1 | grep epiphany-browse | awk '{ totuse = totuse + $9 } END { print totuse }' -eq 0 ]
then
killall epiphany-browser
fi
done