This post demonstrates bash code checking if program is running
How to check if a program f.e. htop is currently running
#!/bin/bash
PRG=htop
RUNNING=$(pidof "$PRG")
if [ -z "$RUNNING" ]; then
echo "$PRG" is NOT running
else
echo "$PRG" is running
fi