Questions tagged [watch]
watch will execute a program periodically, displaying the output.
135 questions
2 votes
1 answer
141 views
Why does script or watch output look weird in saved text files
I use the script command to save the whole session, but the output in the text file is something weird, and I opened it with the cat command in the terminal, and everything became ok. How can I save ...
0 votes
2 answers
91 views
procps' watch together with ps command truncates command lines
The setup is I have two folders now under my current directory, busybox-1.36.1 and procps-4.0.4, and I also have a service languagetool running with DynamicUser=yes. Now observe the different ...
1 vote
1 answer
70 views
watch with piped command executes differently than command itself
What am I doing wrong setting up following watch command? This works: ls -ltr ~/meteofetcher/data/metar/2024/12 | tail -10 | awk '{ print $9 }' | xargs -I {} grep 'LSZH' {} But this watch "ls -...
-4 votes
1 answer
130 views
Watch command but with shell [duplicate]
I want use shell and see watch on top parallel without switching to another tty. Is theres way to do that?
-1 votes
1 answer
495 views
Watch command: Updates only periodically, not event-based? (Example: Every 2 seconds - every time file x gets saved)
What I'd like to have: Running a command y with watch command and have watch command update only as soon as output of command y has changed. Imagine a bash script with 3 lines of echo output Hello ...
-1 votes
2 answers
101 views
Linux "watch" command showing last 30 lines of nft list ruleset [duplicate]
I want to constantly see last 30 lines of code "nfc list ruleset" in Debian Bash. Something like this: watch -n 1 nft list ruleset | tail -n 30 But above code doesn't show last 30 lines of &...
1 vote
1 answer
448 views
How can I get colored output of `systemd` commands run with `watch` inside xterm?
Somehow I'm unable to get this working with color output, it works but no colors are shown. I'm currently using these alias'es in my bash shell: alias Xterm='xterm -geometry 132x60 +dc +cm -e ' alias ...
-1 votes
1 answer
233 views
How can I 'sudo watch sensors' and 'sudo docker stats' in one window on Ubuntu Server?
I tried watch 'sensors | sudo docker stats' sudo 'docker stats | watch sensors' sudo docker stats | sudo watch sensors So I assume its not possible to display both outputs in one window? Other than ...
4 votes
1 answer
4k views
How to run bash function in "watch" command?
Say I have a function f defined in my bashrc function f() { date } I want to run following command to monitor the output watch f. The command failed with "sh: f: command not found". watch ...
1 vote
0 answers
34 views
Do I have to write a shell script purely to access bash for loops inside of say watch? [duplicate]
I'd like to monitor apps that have inotify instance in real-time with watch using something similar to: watch "for foo in /proc/*/fd/*; do readlink -f $foo; done | grep inotify | sort | uniq -c | ...
1 vote
1 answer
121 views
`watch -n 100 'sh script.sh >> /path/to/output/output.txt` doesn't write to output.txt?
I'm currently executing the following: watch -n 100 'sh script.sh >> /path/to/output/output.txt' & It's been running for 30 minutes (I can verify with ps -ef | grep watch), however there's ...
2 votes
1 answer
253 views
alias for watch command gets stopped?
I create this alias, so that aliases get expanded in the watch statement. > alias w='watch -x bash -i -c' > alias k=kubectl I execute it: > w 'k get pods; echo; k get svc' After two seconds ...
1 vote
0 answers
61 views
how to wrap command with many quotes into watch properly?
I have such a bash command ... psql -c "SELECT datname FROM pg_database WHERE datname LIKE 'efa%' OR datname LIKE 'geocms%';" and am wondering how to wrap this into watch -cd "<...
1 vote
1 answer
67 views
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 ...
0 votes
1 answer
952 views
terminal timer with end time given through bash
so I had the idea of making a bash function that takes in a time in hh:mm:ss (24 hour format) and makes a timer till that time kinda like a one time alarm while also showing how much time is left I ...