watch

watch -n1 $() does not run $() every interval

watch -n1 $() does not run $() every interval watch -n1 $() does not update $(). what is the workaround? here is my example: watch -n1 echo $(( $(date +%s -d "sun") – $( date +%s ) )) this results in Every 1.0s: echo 106602 106602 the expected output should have been: Every 1.0s: echo …

Total answers: 1

I can't wrap a command inside watch

I can't wrap a command inside watch I have this perfectly working command: netstat -tuplean | awk ‘{NR>1; if( $6 ~ /ESTABLISHED/ ) print "33[0;31m" $5 " 33[01;31m"$6;if ($6 ~ /_WAIT/ ) print "33[0;34m"$5 " 33[01;32m"$6}’ I cannot wrap it into a watch command. Here is what I tried: escape all single quotes (‘) watch …

Total answers: 2

How can I watch the 17th (or last, if less) line in files of a folder?

How can I watch the 17th (or last, if less) line in files of a folder? I’m currently using watch head -n 17 * which works, but also shows all lines up to the 17th. Basically, I would like to only show the last line for each file that is shown with my current approach. …

Total answers: 3

Interrupting watch if command execution was successful

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 Freeze updates on command error, and exit after a key press. Example The command: ping …

Total answers: 2

How to run ssh command until succeeded?

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 && exit 1 How can I do this? Asked By: Philip Kirkbride || …

Total answers: 7

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

How to use watch command with a piped chain of commands/programs I usually use 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 like: $ watch ls -ltr|tail …

Total answers: 8

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

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 ~, and I get number of …

Total answers: 2

How to wrap output of watch command?

How to wrap output of watch command? Consider the following command: watch -d “ps -ef | grep java” It gives following output: kshitiz 11369 11285 0 Oct13 ? 00:06:02 /usr/lib/jvm/jdk1.7.0_40/jre/bin/java -Djava.awt.headless=true -Didea.version==14.1.2 -Xmx512m -Dfile.e The output beyond -Dfile.e is truncated or flows off screen. How can I scroll to see the output or word wrap …

Total answers: 2

Perform command every X seconds

Perform command every X seconds I wish to perform a command ever 10 seconds, and have it executed in the background (thereby eliminating watch?). All the answers show something like the following, but this will execute ever 11 to 14 seconds. How can this be accomplished? while true; do # perform command that takes between …

Total answers: 3

Get a refreshing list of running specific processes

Get a refreshing list of running specific processes I want to monitor running python processes with VSZ, RSS %MEM, %CPU etc. One of my priorities is a list refreshing every X seconds. I managed to come to the point of obtaining a refreshing list of processes using ps and watch ps ax | grep python …

Total answers: 2

How to perform the watch command onto expression with pipes?

How to perform the watch command onto expression with pipes? I learned today the wonderful shuf command: ls | shuf shows me a listing of the working direcotry, but thanks to shuf each time I execute this piped command expression with another order. So I thought, why not repeat this expression every second anew, and …

Total answers: 1

Can not evoke watch command with non-integer time option

Can not evoke watch command with non-integer time option I want to start the w command periodically, according to man watch the smallest possible time interval is 0.1. I tried: watch -n1 w (works) watch -n1.5 w (does not work) watch -n0.1 w (does not work) When I try to start the watch command with …

Total answers: 3

watch command smallest -n interval

watch command smallest -n interval What is the smallest interval for the watch command? The man page and Google searches do not indicate what the smallest interval lower limit is. I found through experimentation it can be smaller than 1 second. To test, I ran this command run on a firewall: watch -n 0.1 cat …

Total answers: 3

How to force watch to run under bash

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 Asked By: Rachid O || Source Ok, so there are a few …

Total answers: 3

watch perldoc output preserving formatting

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 Tue Apr 8 10:42:43 2014 Uki::Handlers::SOS(3) User Contributed Perl DocumentationUki::Handlers::SOS(3) N NA AM ME E Uki::Handlers::SOS – Studenten-Handler S Sy yn no op ps si …

Total answers: 3

Does watch only monitor the visible output?

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 exit if …

Total answers: 2

'watch'-ing curl yields unexpected output

'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 avail. When playing with curl on it’s own, this output seems nowhere to be found. What …

Total answers: 1

watch command not showing colors for 'git status'

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 colors. Asked By: Andrei || Source When git status is run under watch, it is able …

Total answers: 1