shutdown

Description

Shuts down the Adaptive Server from which the command is issued, its local Backup Server, or a remote Backup Server.

Syntax

shutdown [srvname] [with {wait [="hh:mm:ss"] | nowait}]]

Syntax for clusters:

shutdown {cluster | [instance_name]} [with {wait | nowait}]

Parameters

srvname

is the logical name by which the Backup Server is known in the Adaptive Server sysservers system table. This parameter is not required when shutting down the local Adaptive Server.

with wait

is the default. This shuts down the Adaptive Server or Backup Server gracefully.

hh:mm:ss

is an optional setting that specifies the maximum time the server waits for all running or sleeping processes to finish their job.

with nowait

shuts down the Adaptive Server or Backup Server immediately, without waiting for currently executing statements to finish.

WARNING! Use shutdown with nowait only in extreme circumstances. In Adaptive Server, issue a checkpoint command before executing a shutdown with nowait. Use of shutdown with nowait can lead to gaps in IDENTITY column values.

cluster

(shared disk clusters only) specifies that all instances in the cluster are to shut down.

instance_name

(shared disk clusters only) is the name of a specific instance to shut down.

Examples

Example 1

Shuts down the Adaptive Server from which the shutdown command is issued:

shutdown

Example 2

Shuts down the Adaptive Server immediately:

shutdown with nowait

Example 3

Shuts down the local Backup Server:

shutdown SYB_BACKUP

Example 4

Shuts down the remote Backup Server REM_BACKUP:

shutdown REM_BACKUP

Example 5

Shuts down the current cluster:

shutdown cluster

Example 6

Shuts down the instance “ase1”, but leaves the cluster running:

shutdown ase1

Usage


Specifying a wait time

When the server prepares to down, it:

  1. Performs checkpoint on all the databases

  2. Prevents any new user from logging in

  3. Waits for all running or sleeping processes to finish their job

  4. Performs another checkpoint on the databases, this time with a flag that informs you that you need to flush:

When you use with wait with the hh:mm:ss option, the time you specify is not the meximum total time Adaptive Server takes to shut itself down. Instead, Adaptive Server takes into account the time it takes to perform the first checkpoint, and automatically subtracts this from the time you specified.

For example, if you specify a maximum wait time of 20 minutes and the first checkpoint takes 3 minutes, Adaptive Server allows up to 17 minutes for the processes to finish. If for some reason the second checkpoint takes longer, however, this is not calculated into the with wait hh:mm:ss parameter you specify.

Adaptive Server also accommodates a checkpoint that takes longer than the time you specify in with wait hh:mm:ss. For example, if you specify a wait time of 10 minutes but the first checkpoint takes 20 minutes to complete, Adaptive Server does not interrupt checkpoint midway, but instead waits for checkpoint to complete. When this occurs, Adaptive Server immediately begins to shut down after checkpoint is complete, since the time you specified has passed, and runs the last checkpoint with the flag informing you of the flushes you must perform.


shutdown in a clustered environment

shutdown
go

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

The permission checks for shutdown differ based on your granular permissions settings.

Granular permissions enabled

With granular permissions enabled:

  • To shutdown a SMP server, a cluster instance, or a backup server, you must be a user with shutdown privilege.

  • To shutdown a cluster, you must be a user with shutdown privilege and manage cluster privilege.

Granular permissions disabled

With granular permissions disabled, you must be a user with sa_role.

Auditing

Values in event and extrainfo columns of sysaudits are:

Event

Audit option

Command or access audited

Information in extrainfo

51

security

Server shutdown

  • Roles – current active roles

  • Keywords or optionsshutdown

  • Previous value – NULL

  • Current value – NULL

  • Other information – NULL

  • Proxy information – original login name, if set proxy is in effect

See also

Commands alter database

System procedures sp_addserver, sp_helpserver