Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 May 2024 20:04:04 +0000
From:      Justin Teague <arcadellama@posteo.net>
To:        "Dan Mahoney (Ports)" <freebsd@gushi.org>
Cc:        questions <questions@freebsd.org>
Subject:   Re: EMail on unexpected reboot
Message-ID:  <8C7E76F1-52EE-416E-AFBA-D9BADDC2A231@posteo.net>
In-Reply-To: <9A12F675-BB12-4DD7-84D7-793FEFF63CCA@gushi.org>
References:  <83D445F4-677E-461F-B3FA-AA364B22C653@gushi.org> <CAOyJeZQL2UYfDmMQXV2rBYaP9xf%2Bh_ZC7JmKCJC_6QQs3PzSPw@mail.gmail.com> <9A12F675-BB12-4DD7-84D7-793FEFF63CCA@gushi.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> On 15 May 2024, at 14:25, Dan Mahoney (Ports) wrote:
> Yes, that happens *every* reboot, and I was asking if the system had a =
way of detecting only =E2=80=9Cunclean=E2=80=9D reboots.  Some checkfile =
that=E2=80=99s set on clean shutdown, for example.

I know that `last reboot` will show =E2=80=98boot=E2=80=99 and =E2=80=98s=
hutdown=E2=80=99 entries the accounting database. I haven=E2=80=99t teste=
d this myself, but I suppose an =E2=80=98unclean=E2=80=99 reboot would me=
an you would have two consecutive =E2=80=98boot=E2=80=99 entries? (I=E2=80=
=99m not in a place to test it at the moment.)

If so, then something like the following should work:

@reboot if [ =E2=80=9C$(last reboot | sed -n '2p' | cut -d ' ' -f1)=E2=80=
=9D =3D =E2=80=9Cboot=E2=80=9D ]; then <foo>; fi

- Justin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8C7E76F1-52EE-416E-AFBA-D9BADDC2A231>