Current code of mine is
while true; do ./program; done;
I don’t have access to a linux box right now and only way to do my request will be made on the live server and I don’t want to test and jeopardize something, so I would be happy if I could get some help
Is this the way it should be if I want my program to sleep 2 seconds after each restart?
while true; sleep(2); do ./program; done;
Advertisement
Answer
Almost fine.
sleep
is a program, so pass him the arguments as space-separated list.- logical test (i.e.
true
) should be followed immediately bydo
- If
sleep
is before./program
, the latter is sleeped before, not after. You could consider reordering them.
while true; do ./program; sleep 2; done;