How to Find Linux Reboot Reason?

It typically occurs that we uncover {that a} Linux system has rebooted in an unplanned method or for unknown, apparent causes. Discovering and fixing the foundation trigger can assist stop the recurrence of such issues and stop unplanned downtime.

There are a number of methods we will discover out what prompted a reboot. On this article, we’re going to talk about these methods and the way you should use the instruments and logs out there in a Linux system to troubleshoot such eventualities.

Examine the restart time

You may examine when the system reboot occurred who And final assignments

$ who -b
system boot 2021-02-13 20:51

$ final -x | head | tac
abhishek pts/0 192.168.1.16 Sat Feb 13 19:53 - 19:55 (00:02)
reboot system boot 3.10.0-1160.11.1 Sat Feb 13 19:55 - 20:54 (00:58)
runlevel (to lvl 3) 3.10.0-1160.11.1 Sat Feb 13 19:55 - 20:04 (00:08)
abhishek pts/0 192.168.1.16 Sat Feb 13 19:56 - 20:04 (00:07)
reboot system boot 3.10.0-1160.11.1 Sat Feb 13 20:04 - 20:54 (00:49)
runlevel (to lvl 3) 3.10.0-1160.11.1 Sat Feb 13 20:04 - 20:51 (00:46)
abhishek pts/0 192.168.1.16 Sat Feb 13 20:04 - 20:50 (00:46)
reboot system boot 3.10.0-1160.11.1 Sat Feb 13 20:51 - 20:54 (00:03)
runlevel (to lvl 3) 3.10.0-1160.11.1 Sat Feb 13 20:51 - 20:54 (00:02)
abhishek pts/0 192.168.1.16 Sat Feb 13 20:51 nonetheless logged in
$

Examine system messages

You may additional correlate the reboots you need to diagnose with system messages.

For CentOS/RHEL methods, logs could be discovered at /var/log/messages whereas for Ubuntu/Debian methods is logged in /var/log/syslog. You may simply use the tail command or your favourite textual content editor to filter out or discover particular knowledge.

As could be seen from the logs under, such entries recommend a shutdown/reboot initiated by an administrator or root person. These messages can differ relying on the kind of working system and the way the reboot/shutdown is triggered, however you’ll at all times discover helpful data by wanting on the system logs, despite the fact that it is probably not specific sufficient to pinpoint the trigger every time to set.

Feb 13 19:56:20 centos7vm chronyd[637]: Supply 72.30.35.89 changed with 142.147.92.5
Feb 13 20:00:40 centos7vm chronyd[637]: Chosen supply 162.159.200.123
Feb 13 20:01:01 centos7vm systemd: Created slice Person Slice of root.
Feb 13 20:01:01 centos7vm systemd: Began Session 2 of person root.
Feb 13 20:04:09 centos7vm systemd-logind: System is powering down.
Feb 13 20:04:09 centos7vm systemd: Closed LVM2 ballot daemon socket.
Feb 13 20:04:09 centos7vm systemd: Stopped goal Multi-Person System.

Beneath is considered one of these instructions that you should use to filter out system logs:

sudo grep -iv ': beginning|kernel: .*: Energy Button|watching system buttons|Stopped Cleansing Up|Began Crash restoration kernel' 
  /var/log/messages /var/log/syslog /var/log/apcupsd* 
  | grep -iw 'get well[a-z]*|energy[a-z]*|shut[a-z ]*down|rsyslogd|ups'

Recorded occasions could not at all times be particular. All the time observe occasions that give indicators of warnings or errors that may trigger the system to close down/crash.

Examine audited logs

For methods with auditdit’s a great spot to observe completely different occasions utilizing ausearch instrument. Use the command under to examine the final two audit log entries.

$ sudo ausearch -i -m system_boot,system_shutdown | tail -4

Experiences the 2 most up-to-date shutdowns or restarts. If this studies a SYSTEM_SHUTDOWN adopted by a SYSTEM_BOOT, every part must be fantastic. But when it studies two SYSTEM_BOOT traces in a row or only one SYSTEM_BOOT line, the system almost certainly didn’t shut down correctly. A standard output ought to look one thing like this:

$ sudo ausearch -i -m system_boot,system_shutdown | tail -4
----
kind=SYSTEM_SHUTDOWN msg=audit(Saturday 13 February 2021 A.852:8) : pid=621 uid=root auid=unset ses=unset subj=system_u:system_r:init_t:s0 msg=' comm=systemd-update-utmp exe=/usr/lib/systemd/systemd-update-utmp hostname=? addr=? terminal=? res=success'
----
kind=SYSTEM_BOOT msg=audit(Saturday 13 February 2021 A.368:8) : pid=622 uid=root auid=unset ses=unset subj=system_u:system_r:init_t:s0 msg=' comm=systemd-update-utmp exe=/usr/lib/systemd/systemd-update-utmp hostname=? addr=? terminal=? res=success'
$

The output under accommodates two consecutive SYSTEM_BOOT messages, which can point out an unobtrusive shutdown, though this must be correlated with system logs.

$ sudo ausearch -i -m system_boot,system_shutdown | tail -4
----
kind=SYSTEM_BOOT msg=audit(Saturday 13 February 2021 A.852:8) : pid=621 uid=root auid=unset ses=unset subj=system_u:system_r:init_t:s0 msg=' comm=systemd-update-utmp exe=/usr/lib/systemd/systemd-update-utmp hostname=? addr=? terminal=? res=success'
----
kind=SYSTEM_BOOT msg=audit(Saturday 13 February 2021 A.368:8) : pid=622 uid=root auid=unset ses=unset subj=system_u:system_r:init_t:s0 msg=' comm=systemd-update-utmp exe=/usr/lib/systemd/systemd-update-utmp hostname=? addr=? terminal=? res=success'
$

Analyze a systematized journal

It’s best to have a persistent systemd journal to maintain a persistent journal on disk, in any other case the logs will not be preserved on reboot. For this you can also make the modifications in /and so on/systemd/journald.conf or create the folder your self with the instructions under:

$ sudo mkdir /var/log/journal
$ sudo systemd-tmpfiles --create --prefix /var/log/journal 2>/dev/null
$ sudo systemctl -s SIGUSR1 kill systemd-journald

When completed, you may optionally reboot the system to log a couple of reboot entry, though this isn’t vital.

Use the command under to record the logged boots from the journal:

$ journalctl --list-boots

Right here is the output on my server:

$ journalctl --list-boots
-15 8a7c8034da804ebb9cb063a7553ed0bf Wed 2020-11-18 23:09:05 IST—Wed 2020-11-18 23:17:10 IST
-14 7bbb9542778a4057a91b9d22fcf91735 Wed 2020-11-18 23:17:22 IST—Wed 2020-11-18 23:20:08 IST
-13 f2ee8a61bf4c4f67a12e012855d8b1c3 Wed 2020-11-18 23:20:17 IST—Wed 2020-11-18 23:23:01 IST
-12 1277d19a959f4c33ba944a68c5874d2a Fri 2020-12-11 10:32:44 IST—Fri 2020-12-11 10:43:39 IST
-11 eb4ff97f112445888a5946d1155de1b8 Fri 2020-12-11 10:43:55 IST—Fri 2020-12-11 10:48:18 IST
-10 bf46eff3f9a344d2b28a03ffbf7fff32 Fri 2020-12-11 19:04:30 IST—Fri 2020-12-11 19:31:01 IST
 -9 2acf08368667423c89086579f98efd82 Tue 2020-12-15 17:36:52 IST—Tue 2020-12-15 19:13:10 IST
 -8 b826f223a67d454b94d4413678870f08 Sat 2020-12-19 00:31:54 IST—Sat 2020-12-19 00:44:52 IST
 -7 011e1b29339041b0ae48bbb93fce792f Wed 2020-12-23 23:01:15 IST—Wed 2020-12-23 23:02:44 IST
 -6 f41f5880572e4394938c6dcb4a8b683c Mon 2020-12-28 16:54:11 IST—Mon 2020-12-28 22:54:22 IST
 -5 a2e638dc292a4db2b0a50dd442129c28 Tue 2020-12-29 17:02:16 IST—Tue 2020-12-29 19:39:38 IST
 -4 f6c738df872a48d48daee1962727cca5 Wed 2020-12-30 19:09:30 IST—Wed 2020-12-30 19:20:23 IST
 -3 c876e60ea371460b94e247b40270b18f Thu 2020-12-31 14:36:07 IST—Thu 2020-12-31 15:45:36 IST
 -2 a23c70804ec243f7868c18737f4b7e55 Sat 2021-02-13 20:09:30 IST—Sat 2021-02-13 20:10:44 IST
 -1 94b604a6bf75462dac8c4a4576fdc863 Sat 2021-02-13 20:10:59 IST—Sat 2021-02-13 20:23:18 IST
  0 3ff7e29fa0a34878b7574b7d4d3ccfb5 Sat 2021-02-13 20:24:57 IST—Sat 2021-02-13 21:13:15 IST
$

As you may see, the record accommodates a number of boots. To additional analyze a specific reboot, use:

$ journalctl -b {num} -n

Right here {num} would be the specified index journalctl --list-boots command within the first column.

$ journalctl -b -1 -n
-- Logs start at Wed 2020-11-18 23:09:05 IST, finish at Sat 2021-02-13 21:13:39 IST. --
Feb 13 20:23:18 ubuntumate20vm systemd[1]: lvm2-monitor.service: Succeeded.
Feb 13 20:23:18 ubuntumate20vm systemd[1]: Stopped Monitoring of LVM2 mirrors, snapshots and so on. utilizing dmeventd or progress polling.
Feb 13 20:23:18 ubuntumate20vm systemd[1]: Reached goal Shutdown.
Feb 13 20:23:18 ubuntumate20vm systemd[1]: Reached goal Ultimate Step.
Feb 13 20:23:18 ubuntumate20vm systemd[1]: systemd-poweroff.service: Succeeded.
Feb 13 20:23:18 ubuntumate20vm systemd[1]: Completed Energy-Off.
Feb 13 20:23:18 ubuntumate20vm systemd[1]: Reached goal Energy-Off.
Feb 13 20:23:18 ubuntumate20vm systemd[1]: Shutting down.
Feb 13 20:23:18 ubuntumate20vm systemd-shutdown[1]: Syncing filesystems and block gadgets.
Feb 13 20:23:18 ubuntumate20vm systemd-journald[304]: Journal stopped
$

You may view messages which can be journaled within the output above and spot any anomalies.

Conclusion

It could not at all times be potential to find out the reason for a Linux reboot utilizing a single command or from a single log file. Subsequently, it’s at all times helpful to know the instructions and logs that seize system-related occasions and may scale back the time it takes to seek out the foundation trigger.

The above examples give you a place to begin for troubleshooting. Through the use of a mixture of such instruments and logs, you could be assured that you already know what occurred and the way your system rebooted.

Subsequent, uncover some light-weight monitoring software program for Linux.

Rate this post
porno izle altyazılı porno porno