3

We need to track a status file that is rewritten every few seconds by a server process. The watch command works beautifully for this (i.e. watch cat file.txt), except now the table is several pages long (even on a rotated wide-screen display). We have a dedicated display/monitor that runs this command continuously and we need to be able to scroll up and down the file to find pertinent status values.
I will also note that we are not running screen or tmux since we have dedicated the entire monitor to this status file.

I've searched on the topic (with the best discussion here) but none of the code works on our system (Ubuntu 20). For example:

  • swatch runs and scrolls, but after a few minutes the text gets shredded with each update and becomes unreadable
  • pwatch flickers so badly its not watchable (the watch command by itself has perfectly smooth updates)
  • watch "cat file | tail -n $(($LINES - 2))" has a static offset and does not scroll
  • watchall does not actually scroll (I think there is curses error also)

So now I'm posing the question again. Has anyone found a scrollable version of watch that will work on Ubuntu? Thanks.

3 Answers3

2

How often do you need to scroll the screen, and how often do you need the view to update? If you anticipate needing to scroll, I imagine you're going to spend more than a few seconds looking at any particular instance of the file. Something like the following could work:

#!/bin/sh

file="${1}" while true; do timeout 60s less "${file}" done

  • Thank you for the response. The page is more of a text-based dashboard with continuously updated measured parameters, so we do indeed need to stare at it for a while as we track changing values. And we also need to scroll up and down. At some point this should be moved to a real dashboard, but for now it so much faster to build these with text blocks. – Hephaestus Dec 16 '21 at 06:00
0

Sounds like some kind of log viewer app like klogg would be useful for your use case. https://klogg.filimonov.dev/

0

You can use viddy.

It's a binary that has the basic features of original watch command, including color output and diff highlight, but allows scroll and has a couple more cool features including text search and time machine mode, which allows one go back to the previous versions of the output.

The current one-liner to install it is

wget -O viddy.tar.gz https://github.com/sachaos/viddy/releases/download/v0.3.6/viddy_0.3.6_Linux_x86_64.tar.gz && tar xvf viddy.tar.gz && sudo mv viddy /usr/local/bin

And then you can use it like, for example

viddy -d -n 1 cat file.txt

to get the file contents every second and to highlight the changes. While viddy is running, press ? to get the keyboard shortcuts.

viddy cmd options:

$ viddy -h

Usage: viddy [options] command

Options: -b, --bell ring terminal bell changes between updates -d, --differences highlight changes between updates -n, --interval <interval> seconds to wait between updates (default "2s") -p, --precise attempt run command in precise intervals -c, --clockwork run command in precise intervals forcibly -t, --no-title turn off header --shell shell (default "sh") --shell-options additional shell options --unfold unfold command result --pty run on pty (experimental, not for Windows)