It seems that you are normally not supposed to exit "Forward forever" mode, which is how the manual man less
names the mode you enter when pressing Shift+F.
However, I found a little dirty trick how you can return to normal anyway. It will briefly freeze the command though, so I am not sure if it would be suitable for your server which should probably run uninterruptedly.
Anyway, here is the trick:
I assume that you have started node server.js | less
alredy and pressed Shift+F to enter "Forward forever" mode. Now less
is not reacting to any keypresses any more.
In this state, you could press Ctrl+C to kill the server process and be able to quit less
afterwards by pressing Q (which will however for some reason leave the command as stopped process in your jobs list - you have to run fg
to continue it and let it completely terminate afterwards), but this is not what we want.
Instead, you can also press Ctrl+Z to stop ("freeze") the command and return to your shell prompt. Now quickly type the shell command fg
("foreground") to let the command continue running in foreground. Note that your node
server process is also paused during this short time, you have to consider whether this is acceptable or not.
So now less
is running in foreground again as before, right? Yes, but magically it is no longer in "Forward forever" mode. You can use e.g. the arrow keys again to scroll up and down.
Unfortunately, less
seems to have stopped updating its buffer completely, you can only scroll down to the line at which you froze the command earlier, not any further. The node
server is still running and producing output though, we just have to get less
to refresh again.
The easiest way I found to do that is to simply open less
' help screen and close it again, by pressing the keys H and Q sequentially. Now everything seems to be working fine again.
The cleanest solution however is probably to follow terdon's answer and redirect the output to a temp file, using less
to monitor the file.
less
and return to your shell prompt with thenode
server running in background, or do you just want to getless
back into normal non-following mode where you can scroll through the log instead of watching the latest lines?