Author: Gitesh
Multiuser systems such as Unix should never be just “shut off”. Active users connected to the system are rightfully miffed if their terminals die without warning. Even if the users have all logged out and gone home, there may be background jobs and daemons ticking away. Daemons get mad if their processes are suddenly curtailed.
A less obvious danger lays in the way the Unix file system works. For improved performance, when a file is changed, the disk version of that file is not always updated immediately. Usually, portions of the file to be changed are read into file buffers a part of the RAM memory. The changes may reside in memory for a while before being written to disk. Unix copies the data stored in memory to disk during periods of low processor activity to make the system more efficient. The price you pay for this more efficient use of processor time, however, is that a premature cessation of kernel activity may destroy the data before it is saved to disk. As you saw in the cleanup time section above, the fsck command tests for a corrupted file system, and helps you to repair the damage. But in mending the fule structure, some data may be lost. For all these reasons, Unix example and Linux provides several commands to the super user for a graceful shutdown. If you are in single-user mode and therefore already a root user, there is no need to warn other users to terminate their jobs, but you still have to flush any pending file I/O to ensure the data is saved correctly. Using command like /etc/haltsys, you can achieve this goal.
Executing this kind of command will flush the file buffers, mark the file system as clean, and then halt all kernel activity without any grace period or warning. Any background processes will dies, of course, so it is your responsibility to kill them safely before using “haltsys” command. A message then tells you that it is safe to power down or press any key to reboot. In some Linux system, we can use “SYNC” command to flush file buffers to disk. For flushing entire file buffers to disk use following command in Linux example before execution of shutdown whole system.
sync ; sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
Of course, you can use SYNC command in other Unix flavors for flushing file system buffers from memory to disk. If you enabled direct IO for Oracle database server then also this flushing is essential for Unix example and Linux server for cleaning up memory caches before proceeding for system shutdown or halting system.
Article Source: http://www.articlesbase.com/operating-systems-articles/dont-issue-direct-shutdown-or-halt-in-unix-and-linux-examples-5653678.html
About the Author
Author is having 15+ years experience and providing Database Support and Online Oracle DBA Courses.
Leave a Reply