
Terminal - Commands tagged watch - 38 results
watch 'ls -tr1 | tail -n1 | xargs tail'
This is sample output - yours may be different.
Watches for file modifications in the current directory and tails the file.
watch "lsof -i -P |grep ESTABLISHED |awk '{printf \"%15.15s \\t%s\\n\", \$1, \$9}'"
This is sample output - yours may be different.
Finder localhost:53255->localhost:26172
imagent mycomputer.foo.com:59319->qa-in-f125.1e100.net:5223
imagent mycomputer.foo.com:59339->bos-m015c-new-rdr2.blue.aol.com:443
Google mycomputer.foo.com:58776->qc-in-f125.1e100.net:5222
Google mycomputer.foo.com:60731->qa-in-f125.1e100.net:5222
Google mycomputer.foo.com:60858->qc-in-f125.1e100.net:5222
Google mycomputer.foo.com:60982->qc-in-f125.1e10
Shows which applications are making connections, and the addresses they're connecting to. Refreshes every 2 seconds (watch's default). Test on OSX, should work anywhere watch and lsof work.
watch -d=c -n3 'lsof -itcp -iudp -c php'
This is sample output - yours may be different.
Shows files and processes of the command php
while sleep 1; do clear; cat /tmp/whatever.cue; done
This is sample output - yours may be different.
File contents
Which is beings updated every second
Watch file's contents that is getting overwritten
while sleep 1; do foo; done
This is sample output - yours may be different.
For use when you can't use "watch" (user-defined functions, aliases). This isn't mine - its an alternate posted in the comments by flatcap, and is the shortest and easiest to remember.
watch "asterisk -vvvvvrx 'core show channels' | egrep \"(call|channel)\""
This is sample output - yours may be different.
Every 1.0s: asterisk -vvvvvrx 'core show channels' | egrep "(call|channel)" Wed Aug 29 06:38:08 2012
1 active channel
2 active calls
82 calls processed
This handles when you have a single call or channel. Other commands will strip out the result if there is a single channel or call active because the output changes the noun to be singular instead of plural.
This is sample output - yours may be different.
top accecpts a comma separated list of PIDs.
top '-p' $(pgrep -d ' -p ' foo)
This is sample output - yours may be different.
Like command 10870, but no need for sed
top $(pgrep foo | sed 's|^|-p |g')
This is sample output - yours may be different.
pgrep foo
may return several pids for process foobar footy01 etc. like this:
11427
12576
12577
sed puts "-p " in front and we pass a list to top:
top -p 11427 -p 12576 -p 12577
watch -n 1 "awk 'NR==3 {print \"Signal strength = \" \$3 \"00 %\"}''' /proc/net/wireless"
This is sample output - yours may be different.
watch -n 1 cat /proc/net/wireless
This is sample output - yours may be different.
Every 1.0s: cat /proc/net/wireless Thu Jun 7 05:34:54 2012
Inter-| sta-| Quality | Discarded packets | Missed | WE
face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
wlan0: 0000 70. -36. -256 0 0 0 0 0 0
Values will depend on the driver and the hardware specifics, so you need to refer to your driver documentation for proper interpretation of those values.
watch 'curl -s --location -I http://any.site.or.url | grep -e "\(HTTP\|Location\)"'
This is sample output - yours may be different.
Every 2,0s: curl -s ...
HTTP/1.1 301 Moved Permanently
Location: http://fooo.bar/
HTTP/1.1 302 Moved Temporarily
Location: http://fooo.bar/ho
HTTP/1.1 404 Not Found
Watches the headers of a curl, following any redirects and printing only the HTTP status and the location of the possible redirects.
while true; do iptables -nvL > /tmp/now; diff -U0 /tmp/prev /tmp/now > /tmp/diff; clear; cat /tmp/diff; mv /tmp/now /tmp/prev; slee p 1; done
This is sample output - yours may be different.
@@ -28 +28 @@
- 339 27684 zone_lan_forward all -- br-lan * 0.0.0.0/0 0.0.0.0/0
+ 340 27768 zone_lan_forward all -- br-lan * 0.0.0.0/0 0.0.0.0/0
this alternative shows the differences as they occur so that they are made plain
watch() { while true; do echo "<Ctrl+V><Ctrl+L>Every 2.0s: $@"; date; eval "$@"; sleep 2; done }
This is sample output - yours may be different.
Usage:
watch ls -l
Basic but usable replacement for the "watch" command for those systems which don't have it (e.g. the Solaris I'm trapped on).
Type Ctrl+V to escape the following Ctrl+L which clears the screen. It will be displayed as "^L".
/usr/sbin/asterisk -rx 'core show channels' | grep -m1 "call" | cut -d' ' -f1
This is sample output - yours may be different.
Only the number of calls nothing else.
while true ; do echo -n "`date`";curl localhost:3000/site/sha;echo -e;sleep 1; done
This is sample output - yours may be different.
Fri Oct 14 21:01:01 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:02 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:03 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:05 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:06 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:07 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:08 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:10 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:11 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
Fri Oct 14 21:01:12 UTC 20110b870c606c0548fe6e458791b67720f2ea11c3a5
In this case it runs the command 'curl localhost:3000/site/sha' waiting the amount of time in sleep, ie: 1 second between runs, appending each run to the console.
This works well for any command where the output is less than your line width
This is unlike watch, because watch always clears the display.
This is sample output - yours may be different.
$ tail -f /home/ubuntu/.bash_history
uptime
echo hello
exit
Changes are displayed when they are written to the file
to exit
watch -n 2 -d '/sbin/ifconfig eth0'
This is sample output - yours may be different.
This is sample output - yours may be different.
This is sample output - yours may be different.
This is sample output - yours may be different.
watch 'netstat -anptu |egrep "^Proto|:80 "'
This is sample output - yours may be different.
Every 2.0s: netstat -anptu |egrep "^Proto|:80 " Wed May 18 11:03:25 2011
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 18418/apache
tcp 0 0 64.xxx.183.xxx:80 213.xxx.243.xxx:21370 SYN_RECV -
tcp 0 0 64.xxx.183.xxx:80 213.xxx.243.xxx:6465 SYN_RECV -
tcp 0 0 64.xxx.202.xxx:80 213.xxx.243.xxx:30703 SYN_RECV -
tcp 0 0 64.xxx.202.xxx:80 64.xxx.202.xxx:39600 TIME_WAIT -
tcp 0 0 64.xxx.202.xxx:80 64.xxx.202.xxx:39601 TIME_WAIT -
Shows updated status in a terminal window for connections to port '80' in a human-friendly form. Use 'watch -n1' to update every second, and 'watch -d' to highlight changes between updates.
If you wish for status updates on a port other than '80', always remember to put a space afterwards so that ":80" will not match ":8080".
while cat /proc/net/dev; do sleep 1; done | awk '/eth0/ {o1=n1; o2=n2; n1=$2; n2=$10; printf "in: %9.2f\t\tout: %9.2f\r", (n1-o1)/1024, (n2-o2)/1024}'
This is sample output - yours may be different.
while :; do OLD=$NEW; NEW=`cat /proc/net/dev | grep eth0 | tr -s ' ' | cut -d' ' -f "3 11"`; echo $NEW $OLD | awk '{printf("\rin: % 9.2g\t\tout: % 9.2g", ($1-$3)/1024, ($2-$4)/1024)}'; sleep 1; done
This is sample output - yours may be different.
while [ /bin/true ]; do OLD=$NEW; NEW=`cat /proc/net/dev | grep eth0 | tr -s ' ' | cut -d' ' -f "3 11"`; echo $NEW $OLD | awk '{printf("\rin: % 9.2g\t\tout: % 9.2g", ($1-$3)/1024, ($2-$4)/1024)}'; sleep 1; done
This is sample output - yours may be different.
Just a simple way without the need of additional tools. Of course, replace eth0 with your IF.