Jump to content

Linux tool journalctl follow switch. How to limit number of new entries printed?

I am not really cultured in Linux. The use of journalctl is for a class assignment and I cannot figure out how to get -f (or --follow) to stop printing newly added entries after x number of entries. I have attempted using -n (or --lines=) and some other things but it still will not stop at the specified number.

 

Distribution: SIFT Workstation (VM)

OS: Ubuntu Linux Based

Link to comment
Share on other sites

Link to post
Share on other sites

On 4/7/2021 at 3:30 PM, BeanBun said:

I am not really cultured in Linux. The use of journalctl is for a class assignment and I cannot figure out how to get -f (or --follow) to stop printing newly added entries after x number of entries. I have attempted using -n (or --lines=) and some other things but it still will not stop at the specified number.

 

Distribution: SIFT Workstation (VM)

OS: Ubuntu Linux Based

Happy to help if I can. Can you please copy and paste the exact command you're typing into the terminal. Or perhaps even better, the command and output from terminal as it might prove helpful.   

Based on what you wrote, I would try using --line= argument. The command would look something like this:

sudo journalctl -f --lines=5


Never used journalctl before, hope this helps. 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 month later...

I have tried that before but that will not get it to stop at x amount. It is supposed to but it does not for some reason. Thank you 🙂

Link to comment
Share on other sites

Link to post
Share on other sites

On 4/7/2021 at 9:30 PM, BeanBun said:

I cannot figure out how to get -f (or --follow) to stop printing newly added entries

You can't because this is exactly what -f is supposed to do: follow the journal as entries are added. The --lines argument is not to stop after N entries, it's to show the latest N entries: https://man7.org/linux/man-pages/man1/journalctl.1.html

Quote

       -f, --follow
           Show only the most recent journal entries, and continuously
           print new entries as they are appended to the journal.

       -n, --lines=
           Show the most recent journal events and limit the number of
           events shown. If --follow is used, this option is implied.
           The argument is a positive integer or "all" to disable line
           limiting. The default value is 10 if no argument is given.

 

Just ditch -f if you're only interested in the last N lines.

Crystal: CPU: i7 7700K | Motherboard: Asus ROG Strix Z270F | RAM: GSkill 16 GB@3200MHz | GPU: Nvidia GTX 1080 Ti FE | Case: Corsair Crystal 570X (black) | PSU: EVGA Supernova G2 1000W | Monitor: Asus VG248QE 24"

Laptop: Dell XPS 13 9370 | CPU: i5 10510U | RAM: 16 GB

Server: CPU: i5 4690k | RAM: 16 GB | Case: Corsair Graphite 760T White | Storage: 19 TB

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×