R
R
r3star2018-03-06 20:51:28
bash
r3star, 2018-03-06 20:51:28

How to make the script take the last minute of the record from the file?

Please tell me how to set a parameter in the script so that it takes the last minute, for example
#!/bin/bash
for ii in $(journalctl -p err > erors.txt)
do
sleep
done
-- Logs begin at Mon 2018-03-05 13:09:15 EST, end at Mon 2018-03-05 14:30:34 EST
Mar 05 13:09:34 localhost.localdomain systemd[1]: Failed to start logs in /restar
Mar 05 13:18:07 localhost.localdomain systemd[1]: Failed to start logs in /restar
Mar 05 13:20:28 localhost.localdomain kernel: e1000 0000:00:03.0 enp0s3: Reset a
Mar 05 13:26:17 localhost.localdomain systemd[1 ]: Failed to start logs in /restar
Mar 05 14:08:05 localhost.localdomain systemd[1]: Failed to start logs in /restar
for example, the script was launched at 14:09:00, it should output only the last record to the file =) #(I don’t know how to describe it in another way)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2018-03-06
@r3star

last entry from the file:
but maybe you just want the last entry from the log, then like this:
journalctl -p err -n 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question