Setting rate of execution using while

What can I use to echo current date 1000 times once every second, redirect this output to a file,and then use tail to monitor growth of the file?

I do not see what tail gives you. But. Try this.

dt=`date`
cnt=0;
while [ $cnt -lt 1000 ]
do
   echo $dt
   cnt=$(( $cnt + 1  ))
done > dtfile

>outputfile
while :
do
  cat dtfile 
  sleep 1
done > outputfile &
sleep 1
tail -f outputfile

You may want to learn about the sync command, and how new data is written to disk periodically, not continuously.
Since the kernel keeps all of the data being written to outfile, tail -f will see it all (except the first 990 lines of outfile)

1 Like

Anx thats exactly what I was looking for.