Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Aug 2000 03:49:23 -0500
From:      "Jim C. Nasby" <jim@nasby.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: detecting reboot
Message-ID:  <39AB7913.AA6B9B6A@nasby.net>
References:  <Pine.BSF.4.21.0008291002010.415-100000@dlanor.evertsen.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
Someone please correct me if I'm wrong, but dropping to single user
doesn't reset your uptime. Or maybe I'm not understanding your concern.

If false reports of reboots are acceptable, you could just run something
at boot to check for an uptime of 0 days. That would give a false report
of a reboot if you came out of single user with less than 24 hours of
uptime though.

As an alternative, you could check the uptime in minutes if it's 0
days... but then you have to worry about how long it takes the machine
to boot (I assume that uptime starts running as soon as the kernel
starts running).

Another possibility is setting some kind of flag (touch a file maybe?)
before leaving single user.

What you should probably do though is take a look in rc* and figure out
how it knows to skip fsck on the way out of single user. Hopefully, you
can use that method as well.

Ronald Klop wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> 
> How do I detect in a script in /usr/local/etc/rc.d that the machine just
> rebooted in stead of going to single-user and back to multi-user.
> 
> In the login-log (last | head) is no difference between the two
> situations. And looking at an uptime of 0 days is not really accurate,
> because a shutdown more times a day is possible.
> 
> Anybody has a clue?
> 
> Greetings,
> 
> Ronald.
> 
> - --
> Ronald Klop                                        http://klop.yi.org/
> http://www.FreeBSD.org/                    http://klop.yi.org/~ronald/
> PGP: http://klop.yi.org/~ronald/pgp.txt
>      mailto:ronald@klop.yi.org?Subject=publicpgpkey
> 
> -----BEGIN PGP SIGNATURE-----
> Version: PGPfreeware 5.0i for non-commercial use
> Charset: noconv
> 
> iQA/AwUBOatvHxk9lWSXChWeEQJ5wQCfbl2NabciE13xX+7QgFznjE1zd+wAoKgA
> dCXypY3J/KhH/C0TeX1qzhp5
> =AdDe
> -----END PGP SIGNATURE-----
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message

-- 
Jim C. Nasby (aka Decibel!)                                  /^\ 
jim@nasby.net                                               /___\
Freelance lighting designer and database developer         /  |  \
Member: Triangle Fraternity, Sports Car Club of America   /___|___\

Give your computer some brain candy! www.distributed.net Team #1828
Get paid to surf!! http://www.enteract.com/~nasby/alladvantage.html


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39AB7913.AA6B9B6A>