watch will execute a program periodically, displaying the output.

learn more… | top users | synonyms

28
votes
7answers
23k views

Is there a way to dynamically refresh the less command?

I like the watch command, but it has its limitations. I'm curious to know whether I could mimic the functionality of watch with less. I'm mainly looking for the ability to scroll through my directory ...
14
votes
2answers
2k views

How can I scroll within the output of my watch command?

I use the watch command to see the contents of my directory changing as a script runs on it (via watch ls dir/) It's a great tool, except that I can't seem to scroll down or up to see all of the ...
12
votes
2answers
229 views

Does watch only monitor the visible output?

Does watch only monitor the visible output of a command? Say I'm in a directory with the following contents: $ ls a b c d e f g h i j k l m n If I run watch -g ls -1 I expect it to ...
8
votes
4answers
3k views

Cygwin has no watch command?

I installed Cygwin on my Windows XP to use some of its commands. Now I what to check a file every 2 minutes and want to use watch for this purpose but I see that Cygwin has no such command. Is this ...
8
votes
2answers
1k views

Alternative to watch which support colors

I have a command (phpunit) which has a colored output. According to the watch, command I should be able to use the --color flag to allow color rendering to pass through. However, this isn't working. ...
7
votes
2answers
3k views

Reading from a continuously changing logfile [duplicate]

There is /location/of/thefile, which is a continuously changing logfile. The average density of refreshes is 4 per minute, the possible maximal refresh rate could be 30-40 per minute. Every refresh ...
5
votes
5answers
2k views

How can I run `watch` as a background job?

When I run: watch 'cmd >> output.txt' & the job gets suspended by the system: 3569 Stopped (tty output) Is there a workaround?
4
votes
1answer
638 views

'watch'-ing curl yields unexpected output

I'm trying to watch curl for live feedback on HTTP tweaks. However, when I execute the command, the output is garbled with some download stats. I've tried sending curl's stderr to /dev/null, to no ...
3
votes
4answers
1k views

Output of 'watch' command as a list

I want to do some simple computation of the number of lines per minute added to a log file. I want also to store the count for each second. What I need is the output of the following command as a ...
3
votes
1answer
110 views

watch command to delete files in a directory every N secs

I thought of using watch command to delete files in a directory every N seconds with the command running in background. This is what I was planning to use: nohup watch -n1200 rm -rf ...
2
votes
3answers
196 views

Can I reload variable in a watch command?

Part of my job involves some data handling. One of the tasks is to 'flatten' a set of directories (which we'll call Dir for now), and copy them to a new location called DirFlat. This can take a long ...
2
votes
1answer
416 views

Chaining commands within `watch`

Ok, this is driving me a bit nuts. I'm trying to watch the number of files in a set of subdirectories. find . | wc -l correctly returns the number of sub-folders and files. However, watch 'find . | ...
2
votes
2answers
108 views

How to force watch to run under bash

The problem is that when watch is executed it runs sh and I get this error: sh: 1: func1: not found here is the code: #!/bin/bash func1(){ echo $1 } export -f func1 watch func1
2
votes
2answers
266 views

using watch with ssh

I have a script: export TERM=xterm watch -t -d -n 1 'netstat -veeantpo | grep 43597 when we run this script though ssh, it does not determine the monitor resolution. so lines are wrapped although ...
2
votes
1answer
684 views

watch command not showing colors for 'git status'

I'm trying to get watch to display colors from 'git status'. I've tried running watch with the --color option, as suggested elsewhere here, but, still, watch --color 'git status' doesn't display ...
2
votes
1answer
215 views

How can I extend the wait time for the watch command beyond 4200 or so seconds?

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 ...
1
vote
2answers
22 views

watch perldoc output preserving formatting

When I use watch to follow a perlpod documentation i am writing, the formatting gets mangeled (see NAME and Synopsis sections): Every 2,0s: perldoc lib/Uki/Handlers/SOS.pm ...
1
vote
1answer
152 views

Repeating a text-output terminal command, in a scrollable ncurses-like interface?

man ps says: If you want a repetitive update of the selection and the displayed information, use top(1) instead. ... however, in some cases, I don't like the output of top - I would instead like ...
1
vote
2answers
794 views

How to watch pgrep?

When running a pgrep command with watch it does not only show the actual pgrep output, but also the watch process as well. Example: watch pgrep -lf donothing will show 3 processes, although ...
1
vote
0answers
25 views

Use an alias with watch command [duplicate]

The post repeat command every x seconds shows that watch is the utility that is useful for the invoking a command at fixed interval repeatedly. Now, I have very long commands, and have used aliases ...
0
votes
1answer
40 views

Watch goes blank on refresh [duplicate]

I'm running the following command in watch. Works for the first one but subsequent ones go blank watch diff <(pacman -Q) <(ssh kate "pacman -Q")