I'm looking for a way, to simply print the last X lines from a systemctl service in Debian. I would like to install this code into a script, which uses the printed and latest log entries. I've found this post but I wasn't able to modify it for my purposes.
Currently I'm using this code, which is just giving me a small snippet of the log files:
journalctl --unit=my.service --since "1 hour ago" -p err
To give an example of what the result should look like, simply type in the command above for any service and scroll until the end of the log. Then copy the last 300 lines starting from the bottom.
My idea is to use egrep ex. egrep -m 700 .
but I had no luck since now.