2

I have encountered a limitation of the watch command.

Even though I specify watch -n 14400 to run the command every 4 hours or so, the command executes every 4200 or so seconds, which is about an hour's worth of wait. Otherwise very useful command, is there a way to extend the range beyond 4200 seconds.

I think the limit comes from time being measured in microseconds and 4200 million micro seconds, and 4200 M is 2^32 or something.

manatwork
  • 31,277
Sherry
  • 21
  • 1
  • 3

1 Answers1

3

You can use watch from busybox: install the busybox package and then call it via

 busybox watch -n 14400 THE_COMMAND

In opposite to the normal watch coming with the procps package, it works internal with seconds (and not with microseconds).

But if you need such long periods, you should have at least a look at cron or at as Warren Young pointed out in his comment. With them, you can run commands in the background and do not need a terminal.

jofel
  • 26,758
  • Hi, Thanks Everyone for answering. here's what I tried and what finally works for me: at - not existent on my host. cron - I really want interactive, terminal output at this point. while true; loop - got strange results (mind you the "command" is complicated and involves "less" where I think I got stuck). busybox - not installed on my host. poor man's watch, too complicated for me. What finally worked was to insert sleep 14400 as the one-before-last of the commands inside the watch command. Advantage, I got exactly the same output as with watch, but with an additional sleep 14400 delay. – Sherry Apr 21 '12 at 14:00