Ads

Check out value in brief website for more up-to-date content.

[Linux] how to view today log at 4 pm ?

in Bash script or Linux terminal

%%bash

grep "$(date +"%b %e 16")" /var/log/syslog

in Python

%%python3

from datetime import datetime

from pathlib import Path

tme = datetime.today().strftime('%b %e')+' 16'

log = Path('/var/log/syslog').read_text().splitlines()

print(*[i for i in log if tme in i], sep = '\n')

If you want to get new posts, make sure to subscribe to Value In Brief by Email.