Questions tagged [watch]

watch - execute a program periodically, showing output fullscreen

39 questions
226
votes
4 answers

Using watch with pipes

I'd like to run this command: watch -n 1 tail -n 200 log/site_dev.log | grep Doctrine But it does not run, because "I think" that the grep tries to run on the watch instead of the tail... Is there a way to do something like watch -n 1 (tail -n 200…
Tommy B.
  • 2,609
93
votes
5 answers

bash watch command with colors preserved

From man watch: Non-printing characters are stripped from program output. Use "cat -v" as part of the command pipeline if you want to see them. So how do I use cat -v if I want to see the colored output from: watch ls -al --color
50
votes
8 answers

Store the output of date and watch command to a file

I am a newbie to linux and I am trying to watch a command and try to log it into a file. I tried watch -t -n 10 "(date '+TIME:%H:%M:%S' ; ps aux | grep "pattern" | wc -l)" >> logfile and am expecting a result like TIME: 10:32:30 12 TIME:…
LoudKur
  • 653
32
votes
3 answers

How do I get systemctl to print in color when being interacted with from a non-tty?

When I run a command like this: # systemctl status plexmediaserver I get nicely colored output. But when I run the following command: # watch -n300 --color systemctl status plexmediaserver Is there any way I can do this watch command with color…
cronburg
  • 726
24
votes
3 answers

Using the watch command with an argument that contains quotes

I'm trying to get watch to work correct with commands that contain quotes, and the watch man page isn't very detailed about how quotes work. To give a concrete example, how can I run the following command inside of watch: ps -ef | awk -F' ' '{print…
jonderry
  • 1,027
10
votes
4 answers

How do I use the watch and jobs commands together in Bash?

How do I use the watch command with jobs command, so that I can monitor when a background job is finished? I execute it as follows, but I do not get the output from jobs: watch jobs If I run jobs by itself, I get the following with my test…
dabest1
  • 1,002
10
votes
2 answers

Watch with awk command

How do you watch a command like? awk 'NR%2==0 {printf "%s %8.0f", $1, $5}' filename.txt Preceding this with "watch" gives this error: awk: cmd. line:1: fatal: cannot open file `{printf' for reading (No such file or directory) The answer to: Using…
5
votes
4 answers

Is there a linux command that lets me color-code the result of another command?

I'm running a watch on a command to monitor the number of open connections for a service we're diagnosing. I need to keep an eye on it while doing other work, to help other developers identify when the service is acting up. The result of the watch…
STW
  • 1,908
5
votes
1 answer

Command-line tool to measure how fast a file is growing?

Is there a command-line tool to measure how fast a text file is growing, in units of lines/second? For small-ish files, I can do something with watch and wc -l, but that measures the file anew each time. Usually I want to watch either a huge log…
Ken
  • 355
4
votes
1 answer

Function using watch on command with command line arguments

I want to run watch on a command which uses an optional command line argument, like this: function queue() { watch -n 10 'squeue -p ${1:-default} -o "%.8i" ' } but the command-line argument isn't used, i.e. the default is only ever used. I…
4
votes
2 answers

Continuously check netstat output for a particular program

I have a android emulator running on port 5554. I want to continuously watch the netstat output concerning emulator stuff. Right now I have to manually execute this command every time sudo netstat -plant | grep emulator I thought doing something…
4
votes
1 answer

How do I live monitor on linux what files get accessed created modified and deleted?

How do I monitor from this moment on what files get accessed / modified / created / deleted. (in live mode), similar to fseventer / fslogger?
3
votes
1 answer

How can I get gnu watch to run in the background?

If I start a watch command in the background, it stops. Bringing the job to the foreground makes it run again, but I want this to run in the background. $ watch ./do-something.sh & [1] 97673 [1]+ Stopped watch ./do-something.sh I…
tobym
  • 212
  • 2
  • 8
3
votes
3 answers

TV Tuner to record / show multiple channels at the same time

I need a cheap mode to record / watch multiple TV channel at the same time on a single PC. Can anyone recommend me any solution(TV Tuner, Application) that can help me solve this problem?
mxg
  • 310
3
votes
1 answer

Is there a Unix command to record changes to output of another command?

I have a long running operation that affects some state. That state is shown by running a certain command, say showst. I want to see have a log of all the possible outputs showst will display during that long running operation. For a short operation…
1
2 3