Shutting Down the System
Fortunately, shutting down the Linux system is much simpler than booting and startup. However, it’s not just a matter of hitting the reset switch. Linux, like all Unix systems, buffers disk reads and writes in memory. This means disk writes are delayed until absolutely necessary, and multiple reads on the same disk block are served directly from RAM. This greatly increases performance as disks are extremely slow relative to the CPU.
The problem is that if the system were to be suddenly powered down or
rebooted, the buffers in memory would not be written to disk, and
data could be lost or corrupted.
/sbin/update
is a program
started from /etc/rc.d/rc.sysinit
on most
systems; it flushes dirty buffers (ones that have been changed since
they were read from the disk) back to disk every five seconds to
prevent serious damage
from occurring should the system crash. However, to be completely safe,
the system needs to undergo a “safe” shutdown before rebooting.
This will not only ensure that disk buffers are properly synchronized, but
also allow all running processes to exit cleanly.
shutdown is the general, all-purpose command used to halt or reboot the system. As root, you can issue the command:
/sbin/shutdown -r +10
to cause the system to reboot in ten minutes.
The -r
switch indicates the system should be
rebooted after shutdown, and +10
is the amount of time to wait (in minutes) until shutting down. The system will print a warning message to all active ...
Get Running Linux, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.