Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [watch]

watch will execute a program periodically, displaying the output.

0
votes
1answer
30 views

output of watch several commands not clear

I am restoring a database backup on my server and i need to watch output of df -h and restore utility db2pd -utilities. I tried this: watch -n 2 "db2pd -utilities && df -h output(summarized): ...
0
votes
1answer
200 views

How can I use the watch command to run a bash script and monitor output file? [closed]

So I have a bash script "example.sh" that will write into an output file, say "tmp_output.txt". (It will empty the file and rewrite if data already exists in it) How can I use the watch command so ...
2
votes
1answer
55 views

A tool for monitoring progress and ETA of an arbitrary process

I'm looking for a tool that takes two arguments: a command to execute, and a target value The tool should then run the command continuously, look for a number in the output of the command, and ...
0
votes
1answer
75 views

Pipe file containing list of images to sxiv and reflect changes immediadly

Suppose I have a file images.txt which contains for example image1.jpg image2.jpg image3.jpg Then I pipe the images.txt to sxiv and I want that the thumbnail view reflects the changes immediately. ...
0
votes
2answers
67 views

Can you force the SSH “watch” command to append the output instead of overwrite?

I'm attempting to watch my network statistics via putty and want to write the statistics to a log file every one second. I've configured putty to log he ssh session to a log file. However, I'm ...
0
votes
1answer
31 views

Use command output as argument in watch command

I have a watch on jq -r '.' $(ls -t | head -1)" The goal is to apply "jq -r '.'" to the most recently modified file in directory. Unfortunately, the command used to know the last modified file is ...
1
vote
4answers
201 views

Define function in fish, use it with watch

I want to define a function, and call that function every n seconds. As an example: function h echo hello end Calling h works: david@f5 ~> h hello But when using watch, it doesn't... watch ...
2
votes
1answer
43 views

tree(1) colours not properly interpeted by watch(1) even with --color option

I am using a simple combination of commands to "monitor" a bit of my filesystem change: watch and tree. Except I want colours and can't get it. Here's what I thought should work: watch --color 'tree -...
2
votes
2answers
342 views

`watch` command with piping `|` [duplicate]

I want to keep monitoring a specific job on a slurm worload like cluster. I tried to use the watch command and grep the specific id. If the job id is4138, I tried $> watch squeue -u mnyber004 | ...
2
votes
1answer
37 views

Interrupting watch if command execution was successful

I would like to be able to interrupt watch if execution of command was successful. In effect, I'm looking for a reverse behaviour than that offered via --errexit. As per man: -e, --errexit ...
1
vote
1answer
388 views

Using watch or alternative to watch multiple commands at once

While running data-heavy scripts that take a long time to run, I like to use these commands to monitor the status/progress of the script. I can then leave the constantly-updating output open as sort ...
1
vote
0answers
208 views

trying to clear the clipboard

I'd like to automatically clear the clipboard a few seconds after use. #!/usr/bin/env bash LOCKFILE=/tmp/.clearclip-lock if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then exit 1 fi ...
2
votes
1answer
173 views

Watch-command-alias-expansion AND need to use quotes

My questions is similar to the watch question here but with a twist. I need to use quotes, which seem to be stripped by an aliased watch. I want run watch on a custom slurm squeue command: $alias ...
3
votes
2answers
112 views

how to perform a calculation on the output of cat and then format it [closed]

I don't know shell scripting at all, but I have this cat /sys/class/power_supply/BAT0/power_now which gives me the output in milliwatts, which i would like to format as watts and use in watch watch ...
1
vote
1answer
912 views

How to interrupt the watch command?

I have a program which prints some info to stdout and I run it like so: watch -n 0.1 myprogram My problem is that I need myprogram to exit cleanly, calling appropriate destructors to release system-...
0
votes
0answers
49 views

Can the watch command be used as a hook?

Is it possible to use the watch command (in a pinch...ie without installing other software on Redhat) with ls to monitor a directory for files created so that when they are created a command can be ...
1
vote
1answer
1k views

Watch command with ls and shell globs

I tried running the command watch -n1 ls foo/bar* which I want to list files matching foo/bar* every second. However, what actually happens is that the shell expands the glob and what watch runs is, ...
2
votes
1answer
186 views

Bash (sed) script works directly from command line but not through watch

I have the following script to monitor some running processes: $ cat ./print_running.sh #!/bin/bash ps aux | grep 'python energydata.py' | sed -r 's/\{"spectral": 0//;s/, "pp_enable.*y": 0.9,//;s/ "...
1
vote
1answer
58 views

Creating a 'sub-screen', similar to how watch behaves [duplicate]

I have a Python script which generates a lot of different text outputs that require me to clear the screen quite regularly. The problem with this is that once the script is finished, I have a terminal ...
0
votes
3answers
216 views

Make watch reevaluate command

Hi I have a problem running watch command like this: watch cat /proc/$(ps ax | grep processname | grep -v grep | awk '{print $1}')/status The command works when I start it. However, then I restart ...
2
votes
2answers
3k views

How can I run a particular script every second?

I have tried using crontab, but it is limited to minutes. Is there any other option? I have also tried something like: watch -n 1 sh /path-to-script/try.sh But whenever I close the terminal it ...
0
votes
1answer
203 views

why does watch remove the colors from git log

possible duplicate : watch command not showing colors for 'git status' running the following command: watch -n1 git --no-pager log --oneline --graph -20 reproduces what i expect only it strips ...
2
votes
2answers
2k views

Stop watching the output of a particular program after using watch command?

I have come to know that we can use watch command to monitor the output of other command and it prints the output every 2 seconds by default, which is really useful. I start to use it to monitor the ...
3
votes
1answer
66 views

How to periodically watch a file from a list of files

I've a running java project that prints it's output to a file named in according to the current time: 03:45 ==> 03.out 13:24 ==> 13.out etc... Now I want to watch tail of the file currently ...
27
votes
6answers
5k views

How to run ssh command until succeeded?

Sometimes I restart a device and need to ssh back in when it's ready. I want to run the ssh command every 5 seconds until the command succeeds. My first attempt: watch -n5 ssh me@device.local &&...
0
votes
2answers
139 views

What happens in “watch” when the called command has not yet finished?

A server produces large amounts of data which I'd like to download as continuosly as possible. The simplest idea is to just use watch rsync ... As far as I understand, watch will call rsync every 2 ...
0
votes
1answer
320 views

How to open a new terminal window running watch process

I have a menu with an option to watch the contents of a folder every 15 seconds. I know I can watch this folder by using watch -n 15 ls -l, but I need to have this watch process open up in a fresh ...
6
votes
1answer
5k views

Working solution for ``watch ps aux | grep foo`` [closed]

watch ps aux | grep foo is not working: bash: syntax error near unexpected token `}' How can I fix this or is there even a better way?
3
votes
1answer
127 views

Colorize output from sensors

I use sensors to keep an eye on CPU temperatures on the console. This is part of the output: coretemp-isa-0001 Adapter: ISA adapter Physical id 1: +45.0°C (high = +80.0°C, crit = +90.0°C) Core 0: ...
0
votes
2answers
2k views

Is there a way to 'tail -f' a folder? [duplicate]

I need a command that acts like tail -f (displays file changes in realtime), but it should display the new output for all files (even if the new file is created/added). I don't know what files will be ...
0
votes
1answer
491 views

Perform periodic task using BASH and watch command

I'm trying to write a BASH script with the purpose of using watch command to monitor a local git repository for changes from the remote branch and then executing a task. Let's say the script is ...
1
vote
2answers
122 views

Showing list of files in current directory while navigating? (Screen, Linux)

I'm looking for a way to have list of all files/folders of the current directory in my terminal that updates automatically and runs while I'm actively navigating and editing files. I imagine it to ...
0
votes
4answers
107 views

How to repeatedly alternate between two (or more) commands?

I'd like to repeatedly iterate over, alternate between, and/or cycle through multiple commands; in a kind of pattern or loop. The desired end result could be thought of as not totally unlike watch. I'...
3
votes
1answer
684 views

Colored grep output getting fragmented by watch command

I'm trying to run watch, so that it shows me the output from my grep command, while I am running over files and changing things. The usual way of doing this works fine, but lacks colors: watch grep '...
0
votes
3answers
869 views

Break infinite 'while' loop on FreeBSD

I have a barebones FreeBSD system with only a terminal. I would like to monitor zpool status every 15 seconds or so. Usually on "regular" systems I would use watch -n15 but this is not available here. ...
1
vote
2answers
74 views

How to watch a large file for changes that can occur anywhere?

I'd like to watch a file for changes that might occur. Normally, using tail -f file or watch -d cat file would be fine for this. However, the file I am monitoring is too large to fit on one screen, ...
1
vote
2answers
334 views

How to create a debian/watch file? [closed]

Debian has a file called watch file which is used for keeping track of new releases. I tried to create a watch file to see how it works from the Debian wiki and tried to copy the same for a game ...
30
votes
2answers
16k views

How to use watch command with a piped chain of commands/programs

I usually user watch linux utility to watch the output of a command repeatedly every n seconds, like in watch df -h /some_volume/ But I seem not to be able to use watch with a piped series of command ...
1
vote
1answer
698 views

what is the right syntax for watch command

I want to follow the word BLOCK in ufw.log file every two seconds I try this command: sudo watch BLOCK /var/log/ufw.log but I getting: sh: 1: BLOCK: not found what is the right command? Thank ...
1
vote
1answer
3k views

is it possible to monitor the /var/log/secure or /var/log/message using watch command

When I was trying to monitor the /var/log/secure or /var/log/message using watch command the output showed as /var/log/messages: Permission denied. Is it possible to monitor the /var/log/messages and /...
0
votes
1answer
4k views

How to stop a “watch” process

I use "Pleeease" to watch CSS files and automatically compile them when any change happens. I did pleeease watch and then just close the terminal, the wathcing process keeps running. Now I want to ...
1
vote
1answer
4k views

How to start a command every 5 seconds on Solaris?

How to start a command for example ls -la every 5 seconds on Solaris ? . I'm searching for something like watch -n 5 ls -la
2
votes
2answers
2k views

Color output of linux command similar to 'watch -d' to highlight differences?

I'm at the beginning of shell scripting etc. and a bit challenged to find the proper way of colorzing a command's repeating output, similar to the -d option in the watch command. I want to see the ...
13
votes
2answers
741 views

Why does `watch` make `ls /tmp` list contents of $HOME?

I'm trying to watch number of files in my /tmp/ directory. For this I thought this command would work: watch sh -c 'ls /tmp/|wc -l' But it appears to work as if ls had no arguments. Namely, I'm in ~,...
3
votes
4answers
70 views

Is there a variant of watch that only refreshes upon receiving a signal?

I have a window that runs a somewhat expensive watch git log ... incantation — expensive enough that it actually looks more like watch -n30 timeout 10 git log ... so that it doesn't excessively ...
0
votes
1answer
623 views

Pretty print output of “kill -USR1”-ing dd

When dd is done it prints a three line summary about the number of read and written segments, the total size and average writing speed. While it does its work, dd is awfully quiet. Not too long ago (...
0
votes
1answer
323 views

Linux `watch` segmentation fault

When I try to use Linux watch with a command which returns color output, I get the error: segmentation fault (core dumped). The command itself is the following: watch --color --no-title --interval 1 ...
3
votes
1answer
477 views

Watch not showing subshell output

Why does the following not output "hello" line? watch bash -c 'echo hello' As this one? watch 'echo hello' I expected to have echo write to bash output directly and this to be read by watch and ...
1
vote
2answers
258 views

Watch: Only print to screen if output has changed since last output

I'm running a process and I'm counting the number of threads with ps huH p <PID_OF_U_PROCESS> | wc -l I can run this thread with watch like this; watch -n 1 ps huH p <PID_OF_U_PROCESS> |...
0
votes
2answers
487 views

watch not displaying output of script

I have a simple script which just uses awk to extract some information from output of ps. When I run this on the terminal, it works fine. But, when I run this script with watch: watch bench_run.sh ...