Hot answers tagged watch
There's no good way to do this in less. You can type F to keep reading at the end of a file (like tail -f). You can type :e and a file name to view a different file, but unfortunately, if you enter the name of the current file, less doesn't reload the file. If you're looking for an alternative to watch ls, here are a few: Modern file managers (e.g. ...
There is watch in cygwin. But it isn't installed by default. You need to install procps package to appear watch. (you can run cygwin installer again and it allows to install only the missed packages without reinstalling the whole cygwin) Instead of watch you can use simple cycle like: while true ; do check file ; sleep 2 ; done
I might be misunderstanding the question, but is there a reason you can't use this? tail -f /location/of/thefile | grep -i -E "foo|bar"
Shift+F will make less similar to tailf. That is, it gets refreshed if more data is appended to the file.
watch is great, but this is one of the things it can't do. You can use tail to show the latest entries: watch "ls -rtx dir/ | tail -n $(($LINES - 2))"
The purpose of watch is to show the results of a command full-screen and update continuously; if you're redirecting the output into a file and backgrounding it there's really no reason to use watch in the first place. If you want to just run a command over and over again with a delay (watch waits two seconds by default), you can use something like this: ...
I found this thread titled: Bug#225549: have watch monitor stderr. That thread is from 2008, but it looks like older versions don't support the watching of anything other than STDOUT. So we're limited to just STDOUT. As for visible there is a lot of language in the info watch and man watch that make me think your observation/assumption is correct. excerpt ...
I'm not sure about your motivations, but maybe this would be enough? while true; do sleep 2; cmd >>output.txt; done & Otherwise, please explain why you really need watch.
Depending on your implementation/version of watch, it may not start a shell to interpret a command line, but instead runs a command that takes as argument the arguments it received itself. So, in that case, if you need it to run a shell command line, you need to start a shell explicitly as in: watch sh -c 'find . | wc -l' See also the inotifywait -rm . ...
Add -t to your ssh. By default when you pass a command to ssh, it doesnt allocate a TTY on the remote host, so the application only has a basic STDOUT pipe to work with. ssh -t foobar 'watch -t -d -n 1 "netstat -veeantpo | grep 43597"'
It seems curl does print the progress stats only when stdout is not a terminal. (e.g. curl -I sandbox.dev|cat would give you these results, too) You can disable these, however. From the manpage -s/--silent Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute.
Simply type: less +F filename This emulates pressing "F" within the editor.
A better option than providing the password on the command line at all is to make a ~/.my.cnf file with the credentials in it: [client] password=something That way they are also protected against someone looking at the ps output, or your shell history. That said, you can turn off the watch title entirely with the -t or --no-title option, which will: ...
I've created a small program that does exactly what you want in python. Find it here, it's called pwatch.
Ok, so there are a few issues with your approach. You are exporting a function, which is not portable between shells. watch executes its commands with /bin/sh, which on your system is not bash. And whatever shell it is, it doesn't respect function exports, so you get the error. Secondly, you can change your command to something like watch bash -c 'func1', ...
Try: watch 'bash -c "diff <(pacman -Q) <(ssh kate \"pacman -Q\")"'
Contrast: $ watch -n 1 "echo $(date)" Every 1.0s: echo Sat Apr 27 03:10:50 CEST 2013 $ watch -n 1 'echo $(date)' Every 1.0s: echo $(date) What you've done is to run echo "($ls DirFlat |wc -l)*100/$FileNum"|bc and date, substitute the output of each command into the shell command watch -n 100 "echo $(…) % $(…)", and run that. You need to prevent the ...
The "F" key when running less will do a "follow" similar to tail -f, but I'm not sure if that will achieve what you're looking for here.
When git status is run under watch, it is able to detect that its standard output is not a terminal, meaning it will not output colors if the color.status setting is set to auto. To force git status to always output colors (even under watch), set color.stats to always, e.g. git config color.status always to set the setting permanently, or as ...
watch is in procps, so install 'procps' package.
It will not only show up on your screen, but also in ps output, in your ~/.bash_history (though that one should only be readable to you and the admins) and possibly in some audit or performance logs. You should not pass passwords as arguments to commands. Arguments to commands should be considered public knowledge. For mysql, use ~/.my.cnf as Michael has ...
Installed the ncurses package and then I get a clear screen on every run. Thank you rush. I ran mine as while true ; do clear; <command> <file> ; sleep 2 ; done such as while true ; do clear; grep ERROR server.log | tail -n 5 ; done
phpunit | cat didn't work unfortunately. However the bash script approach worked great. Thanks! #!/bin/bash while true; do (echo -en '\033[H' CMD="$@" bash -c "$CMD" | while read LINE; do echo -n "$LINE" echo -e '\033[0K' done echo -en '\033[J') | tac | tac ...
I expect it to exit if a file is added or removed I'm pretty sure you're after inotify-tools. My manpage for watch, from procps-ng, says watch runs command repeatedly, displaying its output and errors (the first screenfull).
You can use the -t switch to watch which causes it not to print header. However, that will still clear the screen so you might be better off with a simple shell loop: while sleep 1; do wc -l my.log done One of the advantages is, that you can easily add other commands (e.g. date) and/or pipe the output through sed to reformat it. By the way, if you ...
If using the watch command from procps (which starts a shell to interpret the command line that's made out of the concatenation of its arguments), use: nohup watch -n1200 'rm -rf /var/log/radius/radacct/188.8.131.52/detail-2013*' & With some other implementations, you may have to call the shell manually: nohup watch -n1200 sh -c 'rm -rf ...
You can use watch from busybox: install the busybox package and then call it via busybox watch -n 14400 THE_COMMAND In opposite to the normal watch coming with the procps package, it works internal with seconds (and not with microseconds). But if you need such long periods, you should have at least a look at cron or at as Warren Young pointed out in ...
Alternatively you can wrap it into a shell loop: while sleep 100; do (... your stuff ...) if [ (... process has finished ...) ]; then (... beep or get operator's attention otherwise ...) break fi done
Are you okay with typing the password when you run it? You can read it in a bash script without making it visible in the terminal, saving to history, etc: #!/bin/bash if ! IFS= read -rs -p "Enter password: " password < /dev/tty 2> /dev/tty then echo "Password entry failed" exit 1 fi somecommand -user me -password $password Looking at the other ...
You have to put this into a shell script and let watch call this script then.
Only top voted, non community-wiki answers of a minimum length are eligible