Antonio Pitasi

A personal space for personal thoughts

CLI

Using Less Instead of Tail #

So if you’re used to jump between:

$ tail -F /var/log/yourlog.log

and

$ less /var/log/yourlog.log

You may benefit from this command instead:

$ less -R --follow-name +F yourlog.log
# (maybe create an alias for it...)

While inside less just press ctrl-c to stop tailing and F to resume tailing.

Explanation:

  • -R shows colors (if you have colored logs)
  • +F for “follow”, is equivalent to less -f
  • --follow-name makes less reload the file if the file you were following gets replaced (i.e. rotated)

The actual power is to be able to switch quickly between “tail mode” and stop it to have a better look (or searching for a query).

Note: this works well for single files, if you want to watch multiple files tail has a better output.