An interesting annoyance that just plagued a coworker:

If you less a file that's being appended to, you can hit shift-f to start following the output stream in real time. Then, to stop following the output, you hit ctrl-c, after which you can navigate and search the file as usual.

This does not work when using journalctl. Say you want to follow your nginx log - you'd run journalctl -u nginx, and then the usual shift-f to start following the output. However, when you press ctrl-c, less immediately terminates, rather than exiting the "follow" mode and returning to "navigation" mode as it does when following a file.

Needless to say, this is incredibly annoying. Why is this, and how do I restore the normal functionality?

  • 4
    It's because of the default options that systemd passes to less (see man journalctl section Environment)... Same question as here... – don_crissti Sep 12 '16 at 16:18

As answered over on ServerFault, this is because less is invoked with the K flag, which causes it to die upon recieving a ^C character, rather than returning to its command prompt.

To remedy this, export the variable SYSTEMD_LESS="FRSXM" into your environment. This is the standard set of flags that systemd passes to less, minus the problematic K that makes it impossible to break out of follow mode.

  • 1
    With systemd 241 on Debian 10. I had to set both SYSTEMD_PAGER='less -FRSXM' and SYSTEMD_LESS='FRSXM'. – nyuszika7h Nov 21 '20 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.