{"id":11525,"date":"2021-12-22T16:47:13","date_gmt":"2021-12-22T21:47:13","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=11525"},"modified":"2021-12-22T16:47:16","modified_gmt":"2021-12-22T21:47:16","slug":"safely-restart-centos-rhel-or-ubuntu-linux-servers","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/safely-restart-centos-rhel-or-ubuntu-linux-servers\/","title":{"rendered":"How to Safely Restart CentOS, RHEL, or Ubuntu Linux Servers"},"content":{"rendered":"\n
‘Safely’ is the keyword here. You can probably reboot your server by unplugging it from the socket and pressing the power button. However, that isn’t exactly safe for your data integrity. That’s why in this tutorial we will show your how to safely restart CentOS<\/a> or RHEL Linux<\/a> server.<\/p>\n\n\n\n As we start it is good to note that the commands here work for other Linux distros such as Arch, Ubuntu<\/a>, LinuxMint, Manjaro, Debian<\/a>, Fedora Linux, etc.<\/p>\n\n\n\n In reality, there is no single command to gracefully reboot your CentOS or RHEL server though the current methods are generally safe in almost all situations.<\/p>\n\n\n\n The commands below will all…<\/p>\n\n\n\n shutdown command<\/strong>: This command can be used to schedule a power-off or reboot on your Linux system. The now means the action should be invoked immediately. now is an alias for ‘ shutdown allows for displaying walled messages as shown below:<\/p>\n\n\n\n systemctl command<\/strong>: This is Systemd\u2019s systemctl command that has options for shutting down or rebooting your server. reboot command<\/strong>: This is the symbolic link that is aliased to The halt command<\/strong>: This is the symbolic link that is aliased to poweroff command<\/strong>: This is the symbolic link that is aliased to One thing you may want to do before rebooting your CentOS or RHEL Linux server is to synchronize cached writes to persistent storage as the root user. This can help avoid problems especially in relation to database systems for example PostgreSQL, MySQL<\/a>, and MariaDB<\/a>, etc.<\/p>\n\n\n\n Use this to synchronize cached writes to persistent storage.<\/p>\n\n\n\n If you are running a database server then it would be a good idea to shut it down before issuing the reboot command. That’s it! You now know a new way to safely restart CentOS or RHEL Linux servers as well as other major Linux distros such as Ubuntu, Debian, Fedora, and others.<\/p>\n","protected":false},"excerpt":{"rendered":" ‘Safely’ is the keyword here. You can probably reboot your server by unplugging it from the socket and pressing the power button. However, that isn’t exactly safe for your data…<\/p>\n","protected":false},"author":1,"featured_media":11527,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,16,18],"tags":[121,177,178,180,183,193,354,365,393,424,431,433,449,573,591,598],"yoast_head":"\nDifferent ways to Safely Restart CentOS or RHEL Linux Servers<\/h2>\n\n\n\n
Example:<\/p>\n\n\n\n$ sudo shutdown -r now<\/code><\/pre>\n\n\n\n
-r<\/code> option signifies a reboot. Other options are
-H<\/code> for halt,
-h for power-off<\/code>,
-c<\/code> to cancel a scheduled shutdown,
-k<\/code> Don’t halt\/power-off\/reboot, just send warnings<\/p>\n\n\n\n
+0<\/code>‘ That is zero minutes from the time the command is run. The default is
+1<\/code> (one minute). The other way to set the reboot time is to use the time string in the format
'hh:mm<\/code>‘ for an
hour:minutes<\/code>.<\/p>\n\n\n\n
$ sudo shutdown -r now "CentOS 7 webserver is going down for kernel update"<\/code><\/pre>\n\n\n\n
Example:<\/p>\n\n\n\n$ sudo systemctl reboot<\/code><\/pre>\n\n\n\n
systemctl <\/code>provides a
--force<\/code> option. Please do not pass the –force option unless absolutely necessary such as in emergency cases where the system manager has crashed and you need to shut down the server.<\/p>\n\n\n\n
\/sbin\/systemctl<\/code> used to restart the system.
Usage:<\/p>\n\n\n\n$ sudo reboot<\/code><\/pre>\n\n\n\n
reboot <\/code>command is much easier to type than the two methods above.<\/p>\n\n\n\n
\/sbin\/systemctl<\/code> used to shut down and halt the system.
With this command, you will still need to press the power-off button manually to power off the system.
Example:<\/p>\n\n\n\n$ sudo halt<\/code><\/pre>\n\n\n\n
\/sbin\/systemctl<\/code> to power off your server machine
Example:<\/p>\n\n\n\n$ sudo poweroff<\/code><\/pre>\n\n\n\n
A Better Way to Safely Restart CentOS or RHEL Linux Server<\/h2>\n\n\n\n
# sync;sync<\/code><\/pre>\n\n\n\n
Full Example:<\/p>\n\n\n\n# sync;sync\n# systemctl stop postgresql\n# systemctl stop mysql # for MySQL\/MariaDB\n# systemctl reboot<\/code><\/pre>\n\n\n\n
Conclusion<\/h2>\n\n\n\n