To check if your Linux server has been automatically restarting, you can investigate on several aspects:

  1. System Uptime - Check the last boot time.

  2. System Logs - Inspect logs for shutdown or restart events.

  3. Scheduled Tasks (Cron Jobs) - Look for scheduled tasks that might trigger reboots.

  4. Automatic Updates - Check if updates are configured to trigger a restart.

  5. Kernel Panic or Watchdog Settings - Look for system settings that could trigger an automatic reboot on failure.

  6.  

1. Check System Uptime

You can check the system uptime to see if the server has recently restarted.

Command:

uptime​

Output Example:

14:10:27 up 2 days, 5:43, 1 user, load average: 0.00, 0.01, 0.05​

In this example, the server has been up for 2 days.

Alternatively, you can use:

who -b​

This will show the last boot time:

 system boot 2024-11-10 08:37​

 

2. Check System Logs for Reboot Events

The system logs can give you clues about why the server restarted.

For journalctl (Systemd-based systems):

sudo journalctl -b -1 -e​

 

This shows the logs from the previous boot. Look for messages like systemd-shutdown or reboot.

To check if there were any restarts due to a crash or kernel panic:

 
sudo journalctl -k | grep -i "panic"​

 

For last command (all systems):

last reboot​

 

This command shows the list of all recent reboot events.

Example Output:

reboot system boot 5.15.0-78-generic Fri Nov 10 08:37 - 14:13 (2+05:36)​

 

For older log systems (like syslog or messages):

grep -i "reboot" /var/log/syslog grep -i "shutdown" /var/log/syslog​

 

If your system uses /var/log/messages instead:

 
grep -i "reboot" /var/log/messages grep -i "shutdown" /var/log/messages​

 

3. Check for Automatic Updates

On some Linux (like Ubuntu and CentOS), automatic updates might get the server reboot.

Check if unattended upgrades are enabled (Ubuntu/Debian):

sudo systemctl status unattended-upgrades​

 

Check the configuration:

cat /etc/apt/apt.conf.d/50unattended-upgrades​

 

Look for a line like:

"Unattended-Upgrade::Automatic-Reboot "true";

 

On CentOS/RHEL, check if dnf-automatic or yum-cron is installed and configured for reboots:

sudo systemctl status dnf-automatic.timer​

 

4. Check Cron Jobs for Scheduled Reboots

A cron job might be set up to restart the server periodically.

Check the cron jobs for the root user:

sudo crontab -l​

 

Check the cron jobs in the system-wide /etc/crontab:

cat /etc/crontab​

 

Check the cron jobs in /etc/cron.d

ls /etc/cron.d/​

 

5. Check Kernel Panic

The system may be configured to reboot automatically on kernel panic.

Check Kernel Settings:

cat /proc/sys/kernel/panic​

 

If this value is greater than 0, it means the system will auto-restart after that many seconds following a kernel panic.

Was this answer helpful? 0 Users Found This Useful (0 Votes)