bash check count processes
Simple bash command to check if processes are running:
if [ $(pgrep -f pmon) ] then echo One or more databases running else echo No databases running fi
Syntax gets more complex if you want to check for specific counts of processes:
case $(pgrep -f tnslsnr | wc -l | awk '{print $1}') in 0) echo No listeners running ;; 1) echo One listener running ;; *) echo More than one listener running ;; esac
Leave a Reply