2

I notice that when I use tail -F, I'm still getting a log generated a few minutes ago.

Current date and time

user@svr01:~$ date
Wed Jun 19 00:39:52 +08 2019

tail -F shows data a few minutes before date

user@svr01:~$ tail -F /var/log/syslog
Jun 19 00:34:26 svr01 systemd[1]: isc-dhcp-server6.service: Main process exited, code=exited, status=1/FAILURE
Jun 19 00:34:26 svr01 systemd[1]: isc-dhcp-server6.service: Failed with result 'exit-code'.
Jun 19 00:34:56 svr01 systemd-networkd-wait-online[1485]: Event loop failed: Connection timed out
...

Would it be possible to only view log after current date and time which is after Wed Jun 19 00:39:52 +08 2019 in this case, and not before that?

1 Answer 1

2

Yes, you can tell tail to start with no lines from the file, and it will only show lines added after it starts running:

tail -F -n 0 /var/log/syslog

By default tail shows the last ten lines of the file(s) it’s asked to process.

1
  • This is amazing. Thank you!! Commented Feb 14, 2021 at 18:12

You must log in to answer this question.