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?
Best Answer
As answered over on ServerFault, this is because
less
is invoked with theK
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 thatsystemd
passes toless
, minus the problematicK
that makes it impossible to break out of follow mode.