LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Server not restarting after shutdown -r now command (https://www.linuxquestions.org/questions/linux-server-73/server-not-restarting-after-shutdown-r-now-command-4175627362/)

mackeyma 04-10-2018 06:22 AM

Server not restarting after shutdown -r now command
 
Running RHEL 7.4 on an dual quad core Xeon server (Nehalem chipset).

I ran Ubuntu for years without this problem but now every time I restart the server it fails to boot and I have to manually power cycle it.

Very annoying to have to go to the server room after every kernel upgrade

MensaWater 04-10-2018 10:33 AM

Try "shutdown -r 0" instead. 2 less characters to type.

However, "shutdown -r now" also should work.

Note that if there is something preventing stop of services shutdown can fail (regardless of Linux distro). If you're having to power cycle every time you might want to open a console to do your shutdown and see where it hangs and/or what messages it is showing. Also you might want to see what is in your system log (/var/log/system or using systemctl) before the power cycle.

jefro 04-10-2018 01:11 PM

https://access.redhat.com/documentat..._systemd-power

systemd maybe?

MensaWater 04-10-2018 03:30 PM

Quote:

Originally Posted by jefro (Post 5841521)

Thanks for pointing out the article. I should probably start doing what it suggests.

However, it is just a "suggestion". The article notes the existing (non-sytemctl) commands still work.
Quote:

The commands listed in Table 10.8, “Comparison of Power Management Commands with systemctl” are still available in the system for compatibility reasons, but it is advised that you use systemctl when possible.
I tested both "shutdown -r 0" and "shutdown -r now" on RHEL7 before my initial reply to OP. That is why I opined he may be having other issues preventing the shutdown from completing.

mackeyma 04-10-2018 03:33 PM

Yeah I've tried all variations of shutdown, reboot, poweroff. There are no PolicyKit rules set that restriction shutdowns, I have verified that shutdown -r now works as expected at the server.

So it only fails when connected via ssh. I have a few more ideas to try tomorrow, but I had to quit for today.

MensaWater 04-10-2018 03:35 PM

Quote:

Originally Posted by mackeyma (Post 5841348)
it fails to boot and I have to manually power cycle it.

So on reread I noticed you're saying it "fails to boot". Does that mean it is in fact shutting down but not coming up after the shutdown? This sounds more like an issue with your BIOS settings than the shutdown itself.

mackeyma 04-10-2018 03:58 PM

SUCCESS! I finally found a work-around that will surely yield an explanation for this problem.

If I log in using ssh as root then all is well: 'shutdown -h now' works as expected. It is only when the command. is executed using sudo or in a root shell started with sudo that there is a problem.

Must be an issue with a process dying during the shutdown process when initiated using sudo to elevate privileges. Very strange, as there was no indication that permissions were involved.

jefro 04-10-2018 04:23 PM

Or start using the new commands?

Table 10.8. Comparison of Power Management Commands with systemctl


ssh to root is bound to lead to trouble.

MensaWater 04-11-2018 09:03 AM

Quote:

Originally Posted by mackeyma (Post 5841580)
If I log in using ssh as root then all is well: 'shutdown -h now' works as expected. It is only when the command. is executed using sudo or in a root shell started with sudo that there is a problem.

Must be an issue with a process dying during the shutdown process when initiated using sudo to elevate privileges. Very strange, as there was no indication that permissions were involved.

Here you say "-h" but your original question was about "-r". "-h" is not a reboot but rather a halt so you would of course have to power up after a halt.

It seems unlikely sudo is the culprit. In my tests I ran via sudo for both "shutdown -r 0" and "shutdodwn -r now" and didn't see the issue you had. Also those tests were run via PuTTY (ssh) sessions into the system as myself then doing the "sudo su -" to become root.

Is it possible you did "sudo su" instead of "sudo su -" to become root. The former wouldn't invoke root's environment files (bashrc, profile, etc...). There's a lot in PATH for root that non-root users typically wouldn't have.

mackeyma 04-11-2018 09:21 AM

Sorry for the typo - it was '-r' of course.

MadeInGermany 04-15-2018 05:38 AM

If
su -
or
sudo su -
works but not su or sudo then there might be a check for the real uid in shutdown/reboot. Then it should say so ("need to really be root"), or there is a bug.
Furthermore, there might be a bug in systemd, wrongly relying on the privileges of systemd-login.
One of the reasons I dislike systemd: they are excellent programmers who dare to integrate some powerful mechanisms, but they do not have the full picture i.e. have not understood the principles that make Unix so secure and flexible.

MensaWater 04-16-2018 08:08 AM

Quote:

Originally Posted by MadeInGermany (Post 5843340)
If
su -
or
sudo su -
works but not su or sudo then there might be a check for the real uid in shutdown/reboot. Then it should say so ("need to really be root"), or there is a bug.

The OP never wrote about one working and the other not. However, I did and I disagree with what you say about a bug.

I explained that the environment for the root user is NOT invoked if you don't add the "-" to the su and that there are things in the root user's environment that typically are not in regular user environments. If you do it without the "-" then you're telling root to keep (inherit) the environment of the reguluar user that ran the su. This is true whether you do it with su and password or sudo su.

Shahbaz_Mansuri 04-25-2018 12:18 AM

Quick Reboot (forcefully) Linux.
 
Quote:

Originally Posted by mackeyma (Post 5841348)
Running RHEL 7.4 on an dual quad core Xeon server (Nehalem chipset).

I ran Ubuntu for years without this problem but now every time I restart the server it fails to boot and I have to manually power cycle it.

Very annoying to have to go to the server room after every kernel upgrade









#reboot -f
use this command. this used for quick reboot(forcefully) the System.


All times are GMT -5. The time now is 04:48 AM.