#!/bin/bash SLEEPTIME=60 while :; do VAR=$(asterisk -rnx "iax2 show peers" | grep --binary-files=text "192.168." | wc -l) sleep $SLEEPTIME done ./test.sh & [1] 28301 # [1]+ Stopped ./test.sh # ps aux: root 28301 0.0 0.0 3616 1224 pts/7 T 21:40 0:00 /bin/bash ./test.sh root 28302 0.0 0.0 3616 1228 pts/7 T 21:40 0:00 /bin/bash ./test.sh root 28303 0.0 0.0 4080 1492 pts/7 T 21:40 0:00 asterisk -rnx iax2 show peers root 28304 0.0 0.0 2756 624 pts/7 T 21:40 0:00 grep --binary-files=text 192.168. root 28305 0.0 0.0 2700 500 pts/7 T 21:40 0:00 wc -l