i need to get the running time of a program as soon as it is closed and i came up with this
start=`date +"%M"`
while [ `pgrep vlc` ];do
echo vlcopen > /dev/null
done
stop=`date +"%M"`
[ $stop -lt $start ]&&time=$[ 60-$start+$stop ]||time=$[ $stop-$start ]
echo $time > time.txt
and it does the job but this is highly inefficient and takes a lot of cup usage how do i do this more efficiently
man time
. We have a tool for that. – waltinator May 31 '21 at 18:10