Technical article 103407

Is it necessary to type sync before typing haltsys or reboot?

OpenServer 6.0.0OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6OpenServer 5.0.7UnixWare 7.0.0UnixWare 7.0.1UnixWare 7.1.0UnixWare 7.1.1UnixWare 7.1.2UnixWare 7.1.3UnixWare 7.1.4

Written · Last revised

Problem

Is it necessary to type sync before issuing the haltsys or reboot commands?

Solution

No, it is not necessary to type sync before issuing the haltsys or reboot commands.

The commands haltsys and reboot are shell scripts that are in
the /etc directory.  Both of these scripts call sync() from
within the script to flush or write out the buffer cache before
shutting down.
Both of the scripts issue sync() twice because the kernel
synchronization will prevent the second sync() from beginning
until the first sync is done.  This guarantees that the buffer
cache is written to disk before the file systems are unmounted.
* IMPORTANT NOTE *
The reboot and haltsys commands halt the system immediately.
This command should only be used in single user mode.  If there
are any users logged into the system when the reboot or haltsys
command is given, they are logged out and their work in progress
is lost.  In addition, network servers and other programs are
terminated abruptly and could create problems when they are re-
started.

It is recommended to use the "shutdown" command to shut a server down, for example:

# shutdown -y -g0 -i6
for an immediate reboot.
NOTE:      In order to determine when a server is shutdown then you can do the
           following:

Add the following line to the commands, "reboot", "haltsys" and "shutdown" so running of these commands can be logged:

/usr/bin/logger "$0 initiated!"

This will write an entry into the "syslog" file.

In addition, you may wish to create a /etc/rc0.d/K00shutdown script to track if an "init 6" was ran:

:
# K00shutdown
echo "Logging Shutdown in syslog!"
/usr/bin/logger "$0 initiated!"

For OpenServer, you will also see a record of the shutdown process in /etc/rc0.d/messages.

This implementation is optional as if the syslog is not able to be written too then this might cause delays in the reboot cycle.

An immediate reboot can be initiated with:

# sync
# sync
# uadmin 2 x

(Where x is 0 for a shutdown - "The Server has halted and may be..." 1 for an automatic reboot and 2 for a quick shutdown - "Press any key to reboot".

If the 'sync' has not been used then it may mean the filesystems

To determine when a server was started, run "who -b".

From the Xinuos technical article database, record 103407. Reproduced with permission. The original is at www.sco.com/ta/103407, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.