I want to write a php script for monitoring particular process using top command and write into the file.
I use top -p pid
for monitoring a particular process and also i write a shell script for that.
#!/bin/bash
FILE="/home/test/nik/myscriptoutput2";
TIMEOUT=5;
PROCNAME='init';
counter=0;
echo 'counter value is :- '$counter
while [ $counter -lt 3 ]
do
echo 'inside while'
top -b -n 1 |grep $PROCNAME >> $FILE
sleep $TIMEOUT
counter=$((counter+1))
echo $counter
done
echo 'while loop end'
This script will monitor init process after 5 sec for 3 times and write the it into file.
How can I write the same script in PHP?