We are happy to advise you
Gracefully shutting down Linux
How to shut down the system in a secure way.
Commands to gracefully shutdown Linux
Shut down gracefully and immediately
$ shutdown -h now
Shut down gracefully after X number of minutes
$ shutdown -P +30
(P stands for Power Off)
This will shut the machine down after 30 minutes.
To shut down at a specific hour run;
$ shutdown -P 3:00
This will shut the machine down at 3:00 AM
To cancel a pending/scheduled shutdown just do;
$ shutdown -c
The shutdown command will trigger the proper Init level resulting in the OS gracefully stopping all running services. Any stuck processes will be terminated using a kill -9 command then the machine will halt.
Important to note
When the time argument is used, 5 minutes before the system goes down the system will create a /run/nologin file to prevent users from logging into the system as it prepares for shutdown.
The halt, poweroff and reboot commands can also be used to shut the machine down.
$ reboot -P
(P also stands for Power Off)$ halt
If you want to forcefully halt the machine you can do;
$ halt -f or reboot -f