Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
6  
Are you sure watch is the right command here? Maybe you want at or a crontab entry instead. –  Warren Young Apr 20 '12 at 6:13
2  
Or even while true; do command; sleep 14400; done, for less permanent setups. –  jw013 Apr 20 '12 at 6:18
1  
The watch command is coming with procps and is not a bash internal. I'll edit the question accordingly. –  jofel Apr 20 '12 at 8:17
3  
To add to @jw013's hack: sleep also takes human postfixes, so sleep 4h would seem fitting. I made a poor man's watch which might be useful. –  gamen Apr 20 '12 at 9:56

1 Answer 1

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.