I have a script that is run every hour that checks the CPU temperature. If it is running hot it sends me a notification. Sometimes I get notified that it is running hot. It’s always at around midnight. It never happens at any other time but not every day.
I would like to add something in my script to read and save the logs at that moment. But where can I find the logs? I see that dietpi-ramlog is installed and that at the moment it is getting saved to RAM and cleared after an hour. So how can I view these logs and save them myself?
Thanks
How to view the logs
Re: How to view the logs
Logs are usually saved to /var/log. But if you select dietpi-ramlog logging mode, syslogs are not saved there. These are always available via journalctl command. Not sure how these can be read out via script, as by default it opens via pager. Would need an output without pager, to be able to read this output via script. Perhaps journalctl --help gives a hint.
Another option would be to install rsyslog (manually, if you want to keep logs inside RAM). Then /var/log contains:
syslog, daemon.log, and some other possibly interesting system logs.
Another option would be to install rsyslog (manually, if you want to keep logs inside RAM). Then /var/log contains:
syslog, daemon.log, and some other possibly interesting system logs.
Re: How to view the logs
That's great thanks. So In my script it can check journalctl and output to a file which I can check. Thanks
Re: How to view the logs
@MichaIng Is there a way to view the syslog if ramlog is selected?
Re: How to view the logs
@baz123
The default syslog daemon on systemd is systemd-journald. Read it via journalctl: https://manpages.debian.org/stretch/sys ... .1.en.html
The default syslog daemon on systemd is systemd-journald. Read it via journalctl: https://manpages.debian.org/stretch/sys ... .1.en.html
Re: How to view the logs
@MichaIng Thanks. Yes I was aware of that. I wanted to grep the syslog for a specific term which is across different services and I could not see a way to do that via journalctl.
Re: How to view the logs
You can use grep when printing journalctl without pager:
Code: Select all
journalctl --no-pager | grep 'pattern'