<jupyter_start><jupyter_text>How to view Last 30 Minutes Logs?<jupyter_code>%%bash

sed -n "/^$(date --date='10 minutes ago' '+%b %_d %H:%M')/,\$p" \
/var/log/syslog
%%bash

journalctl --since "2020-05-09 11:30:00" --until \
"2020-05-09 12:00:00"
%%bash

for i in {30..1}
do
min=$(date +"%b %_d %H:%M" -d "-$i minute")
sed -n "/$min/p" /var/log/syslog
done<jupyter_output><empty_output><jupyter_text>***<jupyter_code>%%python3

from datetime import datetime, timedelta
from pathlib import Path
from re import search

tdiff = (datetime.now() - timedelta(minutes = 30))
last_30 = tdiff.strftime('%b %_d %H:%M') 
log_lines = Path('/var/log/syslog').read_text().splitlines()

for x in log_lines:
    log_time = search(r'^\w{3}\s+\d+\s\d{2}:\d{2}',x).group()
    if last_30 < log_time:
        print(x)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2079806529625151, 'fraction_numerical': 0.05441354292623942, 'mean_word_length': 4.447368421052632, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '602118', 'license': 'MIT', 'n_tokens_mistral': 388, 'n_tokens_neox': 353, 'n_words': 76, 'path': 'How-To-View-Last-30-Minutes-Logs.ipynb', 'repo_name': 'ManavalanMicheal/Python-Bash', 'size': '827'}