'awk' does not aim to synchronize cached writes to persistent storage.
'sync' does. To call it every 5 seconds:
while sleep 5
do
sync
done
But you do not want a hard-coded value. A default is good though. Also, for
greater performances, you should be able to give the list of the files to
sync. That gives a script such as:
#!/bin/sh
if [ -z "$1" ]
then
while sleep 5
do
sync
done
fi
if [ -z "$2" ]
then
while sleep $1
do
sync
done
fi
period="$1"
shift
while sleep $period
do
sync -d "$@"
done
Type Ctrl+C to terminate.