[HOW TO] make journalctl record restart/shutdown actions

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
User avatar
Larry78723
Level 6
Level 6
Posts: 1397
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

[HOW TO] make journalctl record restart/shutdown actions

Post by Larry78723 » Tue Oct 08, 2019 2:36 pm

I found a way to make journalctl record what is happening during a reboot or shutdown. This would be helpful in diagnosing long reboot/shutdown issues.
In order to accomplish this, the following change must be made:

In /etc/systemd/journal.cont the line "Storage=auto" needs to be uncommented and replaced with "Storage=persistent". Save the changes and Reboot.

Also, per Pjotr's post, in order to prevent a potential explosion of logs (and consumption of disk space), better couple that with changing #SystemMaxFiles=100 into SystemMaxFiles=10 (note the removal of the hash tag)

Journalctl will now include the reboot/shutdown process.


Reference: http://debian.2.n7.nabble.com/Bug-83263 ... 97613.html
Last edited by Larry78723 on Tue Oct 08, 2019 3:18 pm, edited 2 times in total.
Image

User avatar
Pjotr
Level 21
Level 21
Posts: 13521
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: How to make journalctl record restart/shutdown actions

Post by Pjotr » Tue Oct 08, 2019 2:57 pm

In order to prevent a potential explosion of logs (and consumption of disk space), better couple that with changing #SystemMaxFiles=100 into SystemMaxFiles=10 (note the removal of the hash tag). :wink:
Tip: 10 things to do after installing Linux Mint 19.2 Tina
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

User avatar
Larry78723
Level 6
Level 6
Posts: 1397
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: How to make journalctl record restart/shutdown actions

Post by Larry78723 » Tue Oct 08, 2019 3:11 pm

@Pjotr, thanks for pointing that out. I'll edit the post to include it.
Image

gittiest personITW
Level 5
Level 5
Posts: 619
Joined: Tue May 28, 2019 4:27 pm

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by gittiest personITW » Tue Oct 08, 2019 3:34 pm

Would the following command do the job or would it make someone very unhappy?

Code: Select all

sed -i "s/#Storage=auto/Storage=persistent" -e "s/#SystemMaxFiles=100/SystemMaxFiles=10" /etc/systemd/journald.conf

User avatar
Larry78723
Level 6
Level 6
Posts: 1397
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by Larry78723 » Tue Oct 08, 2019 4:47 pm

It looks like it should work.
Image

gittiest personITW
Level 5
Level 5
Posts: 619
Joined: Tue May 28, 2019 4:27 pm

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by gittiest personITW » Tue Oct 08, 2019 4:51 pm

Doh - just tried it and got
sed: -e expression #1, char 39: unterminated `s' command

User avatar
Larry78723
Level 6
Level 6
Posts: 1397
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by Larry78723 » Tue Oct 08, 2019 5:04 pm

Well, at least it you an error rather than screwing things up. I'm not good with sed commands so let's wait for someone who is.
Image

gittiest personITW
Level 5
Level 5
Posts: 619
Joined: Tue May 28, 2019 4:27 pm

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by gittiest personITW » Tue Oct 08, 2019 5:06 pm

It says in journald.conf that if the file is deleted it will just make a new one by default, so, in theory, should be ok.
I'll spend another few minutes on it before bedtime.

gm10
Level 19
Level 19
Posts: 9245
Joined: Thu Jun 21, 2018 5:11 pm

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by gm10 » Tue Oct 08, 2019 5:16 pm

This entire thread is very much missing the point. If your journalctl did not show data from your last session that means you deleted the /var/log/journal directory, which exists by default (used BleachBit recently?).

Restoring that directory is all you need to do, all the other changes are irrelevant to this issue and also misinformed mainly because the only difference between storage=auto and storage=persistent is that the latter will always recreate the directory automatically whereas the former will choose volatile storage if you deleted it, assuming you knew what you were doing.

The average user does not have to do anything because this all works correctly out of the box.
Tune up your LM 19.x: ppa:gm10/linuxmint-tools

User avatar
Larry78723
Level 6
Level 6
Posts: 1397
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by Larry78723 » Tue Oct 08, 2019 5:19 pm

@gm10, per the reference in the OP, they specifically requested the change to record the sequence from clicking the button to actual restart/shutdown.
Image

gittiest personITW
Level 5
Level 5
Posts: 619
Joined: Tue May 28, 2019 4:27 pm

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by gittiest personITW » Tue Oct 08, 2019 5:32 pm

OK, one at a time does it. Will figure it out one day.

Code: Select all

sudo sed -i 's/#Storage=auto/Storage=persistent/' /etc/systemd/journald.conf
sudo sed -i 's/#SystemMaxFiles=100/SystemMaxFiles=10/' /etc/systemd/journald.conf

gm10
Level 19
Level 19
Posts: 9245
Joined: Thu Jun 21, 2018 5:11 pm

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by gm10 » Tue Oct 08, 2019 5:41 pm

Larry78723 wrote:
Tue Oct 08, 2019 5:19 pm
@gm10, per the reference in the OP, they specifically requested the change to record the sequence from clicking the button to actual restart/shutdown.
That's on Debian, my post was about Mint. But anyway, if you believe you see an actual difference in log contents between auto with /var/log/journal and persistent then I shall not stand in your way. ;)
Tune up your LM 19.x: ppa:gm10/linuxmint-tools

User avatar
Spearmint2
Level 16
Level 16
Posts: 6781
Joined: Sat May 04, 2013 1:41 pm
Location: Maryland, USA

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by Spearmint2 » Tue Oct 08, 2019 7:01 pm

Why not just use the Log Viewer? It looks better in there anyway.
All things go better with Mint. Mint julep, mint jelly, mint gum, candy mints, pillow mints, peppermint, chocolate mints, spearmint,....

User avatar
smurphos
Level 12
Level 12
Posts: 4355
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: [HOW TO] make journalctl record restart/shutdown actions

Post by smurphos » Wed Oct 09, 2019 2:43 am

Code: Select all

journalctl -b1 -r
to show the shutdown log messages (in reverse order) from the last shutdown. It all appears to be there with no tweaks from me.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Post Reply

Return to “Tutorials”