Is it possible in Linux command line to have a command repeat every n seconds?
Say, I have an import running, and I am doing
ls -l
"watch" does not allow fractions of a second in Busybox, while "sleep" does. If that matters to you, try this:
while true; do ls -l; sleep .5; done
sleep
already returns 0
. As such, I'm using:
while sleep 3 ; do ls -l ; done
This is a tiny bit shorter than mikhail's solution. A minor drawback is that it sleeps before running the target command for the first time.
while true; do
sleep 5
ls -l
done
Watch every 5 seconds ...
watch -n 5 ls -l
If you wish to have visual confirmation of changes, append --differences
prior to the ls
command.
According to the OSX man page, there's also
The --cumulative option makes highlighting "sticky", presenting a running display of all positions that have ever changed. The -t or --no-title option turns off the header showing the interval, command, and current time at the top of the display, as well as the following blank line.
Linux/Unix man page can be found here
You can run the following and filter the size only. If your file was called somefilename
you can do the following
while :; do ls -lh | awk '/some*/{print $5}'; sleep 5; done
One of the many ideas.
A concise solution, which is particularly useful if you want to run the command repeatedly until it fails, and lets you see all output.
while ls -l; do
sleep 5
done