LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   seeking "first log entry" during a reboot (https://www.linuxquestions.org/questions/linux-security-4/seeking-first-log-entry-during-a-reboot-830806/)

SaintDanBert 09-07-2010 12:34 PM

seeking "first log entry" during a reboot
 
Under Ubuntu Lucid, the "upstart" style gets used during system startup.
How do I discover the absolute first log entry (syslog or messages) that happens after a restart.

As I look at the logs, it seems that the "first message" varies quite a bit. I hope that there is a better way to look at things.

I hope, too, that when the kernel launches upstart (/sbin/init?) there is some always present log entry that announces a system startup.

Merci d'avance,
~~~ 0;-Dan

anomie 09-07-2010 12:41 PM

On RHEL systems, I normally just open /var/log/messages with the less(1) pager, jump to the bottom ("G"), and then search backwards for restart ("/restart", followed by "N").

This isn't perfect, but it usually works, because syslogd doesn't get restarted very often under normal circumstances. If you need something more precise (i.e. for the purposes of a script that parses the log out) you might want to create your own init script and have it put something obvious in the kern (or whatever facility) messages using logger(1).

YMMV with Ubuntu. :)

SaintDanBert 09-07-2010 04:25 PM

Quote:

Originally Posted by anomie (Post 4090555)
On RHEL systems, I normally just open /var/log/messages with the less(1) pager, jump to the bottom ("G"), and then search backwards for restart ("/restart", followed by "N").

This isn't perfect, but it usually works, because syslogd doesn't get restarted very often under normal circumstances. If you need something more precise (i.e. for the purposes of a script that parses the log out) you might want to create your own init script and have it put something obvious in the kern (or whatever facility) messages using logger(1).

YMMV with Ubuntu. :)

Under sysVinit, I'd added something to /etc/rc.local or an /etc/rcX.d/S00something script.

I'm trying to discover what Upstart wants instead.

~~~ 0;-Dan

anomie 09-07-2010 05:48 PM

Fair enough - so my RHEL analogy is probably irrelevant.

If I were tasked with what you're trying to do, I would start here:
http://upstart.ubuntu.com/getting-started.html

Matir 09-07-2010 07:21 PM

The first message after a reboot will be from the kernel, and since it is at boot time 0, it will contain "[ 0.000000]" on systems (like Ubuntu) that tag the kernel messages with a time. So that should give you a good starting point.

SaintDanBert 09-08-2010 02:09 PM

Quote:

Originally Posted by Matir (Post 4090870)
The first message after a reboot will be from the kernel, and since it is at boot time 0, it will contain "[ 0.000000]" on systems (like Ubuntu) that tag the kernel messages with a time. So that should give you a good starting point.

That is a great clue... THANKS!

I have my shutdown scripts accomplish a logrotate so that each operator requested reboot gets a mostly fresh log. If there is more than one 'restart' in a log, I'll know it was unscheduled or unrequested.

Merci, d'avance,
~~~ 0;-Dan

SaintDanBert 09-08-2010 02:14 PM

... more about UPSTART
 
Quote:

Originally Posted by anomie (Post 4090806)
Fair enough - so my RHEL analogy is probably irrelevant.

While they may not be useful to me, they are likely useful to someone else. I've learned that well intentioned answers have value somwhere.
-- much like "it's 5 o'clock somewhere" (grin)

Quote:

Originally Posted by anomie (Post 4090806)
If I were tasked with what you're trying to do, I would start here:
http://upstart.ubuntu.com/getting-started.html

"Upstart" responds to events.
Q1: Where do these events come from? Does each driver (kernel module) have responsibility to throw relevant events? Is there an API or SPI for said event throwing?

Q2: Where do I read about boot-time event creation and any API or SPI?

Merci d'avance,
~~~ 0;-Dan


All times are GMT -5. The time now is 05:49 PM.