Terminal output to file and screen during update

For an update (from a Ctrl + Alt + F2 terminal) I used this series of commands:

pacman-mirrors |& tee up1.txt
sudo journalctl --vacuum-size=50M |& tee up2.txt
sudo paccache -ruk0 |& tee up3.txt
sudo pacman -Syu |& tee up4.txt

The first three commands worked, that is, gave me output to both file and screen.

But the fourth and last got stuck right after “Retrieving packages.” (“Retrieving packages” was the last line displayed on the screen, and for some ten minutes no new line appeared. I interrupted the process and started over, this time, sending output only to screen and not to file. See screenshot below. It is from the output sent only to screen. Red line indicates where the first round had got stuck.)

Question: Is there a way to send the output of sudo pacman -Syu to both file and screen?

Sources:

pacman already does that by default. Check /var/log/pacman.log. Tip: use tail -N (where “N” is the number of lines you want to see) and pipe it through less. The log even contains timestamps.

1 Like

The log was excellent (I looked at it with gedit). Thank you.

Does that mean

tail -10 /var/log/pacman.log | less

It just gave me the last 10 lines of the log. (I must be getting it wrong.)

This

tail -100 /var/log/pacman.log | less

started, I believe, at the 100th line from the bottom and stopped when the screen was full. Each key press gives me one more line.

Trying to figure out a way to get a key press to give me another screenful or more than 1 line. I would have thought

tail -100 /var/log/pacman.log | less -z10

or

tail -100 /var/log/pacman.log | less -10

should do it, but it gives me a line per key press too.

You know, you can use PgUp/Down keys with less.

There’s also paclog from pacutils package. (It uses stupid double-dash long options only, which you can shorten luckily.)

paclog --g pacman
paclog --af 2023-07-01
paclog --w

Thanks so much! After installing pacutils, this command with PgUp/Down gave me just what I needed:

paclog --af 2023-07-15 | less

But the shortened version (to one hyphen, if that’s what you meant) didn’t work

paclog -af 2023-07-15 | less

(I am not italicizing or giving color to the commands. They seem to just come out that way.)

In addition to the above, in /etc/pacman.conf, if you have VerbosePkgLists uncommented, the packages will be displayed in a table format, rather than all packages run together. One caveat, the terminal width has to be wide enough. So if it isn’t formatted, say “N” and widen the terminal. I haven’t tried it, but I read that you might be able to fake it out, albeit the table won’t be perfect, with COLUMNS environment variable.

The command expac (see links below) looks interesting.

These links might be helpful:

May I suggest another output to capture before and after an update.

{ echo "= AUR Foreign =";pamac list -m|tee >(wc -l);echo "= Orphan =";pamac list -o|tee >(wc -l) ;  } | tee up5a.txt
1 Like

re reading /var/log/pacman.log (or any log, for that matter)

You used the gedit text editor to view it - it will load all of the file and you can
(and will need to)
scroll through all of it to get the bottom of it
to read the last messages added to it.

less /var/log/pacman.log
in a Terminal
will kind of do the same thing - you’ll need to page down to the end of the file …

If you are interested in the most recent addition to such a file
you can list it backwards, like this:

tac /var/log/pacman.log | less

it starts from the end of the file
(cat is starting from the top, tac is starting from the tail)

the piping of the output through less lets you scroll through the whole content in each case

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.