Creating a System Restart Script for Sun Solaris and Linux

Create a script that automatically starts or shuts down SAP ASE or Backup Server when the operating system starts or shuts down.

Prerequisites

Make sure all network resources are available. Your server does not start if the network is not running. Be sure the entry for restarting the server follows any commands in the rc directory for starting network operations. Slow start-up of network operations may prevent servers from starting, even if commands are in the correct order in the rc directory.

Task

You may want to designate a period of time for your server to wait before starting by inserting a sleep command at the beginning of the linked RUN_server_name file you created.

  1. Create a start-up script file with contents such as:
    $SYBASE/$SYBASE_ASE/install/startserver     -f $SYBASE/$SYBASE_ASE/install/RUN_servername

    where $SYBASE/$SYBASE_ASE/install/startserver is the full path name of the startserver utility, and $SYBASE/$SYBASE_ASE/install/RUN_servername is the full path name of the RUN_server_name file for the server.

  2. Copy the script to the /etc/init.d directory, using syntax such as:
    cp script_name /etc/init.d/script_name
  3. Review the contents of the /etc/inittab file to determine the default run level for your operating system. The initdefault entry specifies the default run level, which is usually 2 or 3 for Sun Solaris, and 5 for Linux.
  4. Use the ln command to create a hard link from the RUN_server_name file to the appropriate run control (rc) directory, rc#, where # is the default run level obtained in step 2.
    Use Sun Solaris syntax such as:
    ln /etc/init.d/script_name     /etc/rc#.d/S##script_name
    
    ln /etc/init.d/script_name     /etc/rc#.d/S##script_name

    Use Linux syntax such as:

    Use ln -s to create symbolic links from the script name to the appropriate run control (rc) directory, rc# where # is the run level. Use syntax such as:

    ln -s /etc/init.d/script_name     /etc/rc#.d/S##script_name

    When you type the command to create this link, add an uppercase “S” and a two-digit sequence number preceding the name of the script file. “S” indicates a start-up file. The sequence number is necessary because files in the rc directory are executed in order of their numbers. This file should be executed last, so use a sequence number that follows all existing numbers in ASCII order.

    You can perform an ls command on the rc directory to view existing sequence numbers. For example:
    ls /etc/rc3.d/S* 
    
    returns:
    /etc/rc3.d/S10syslog
    /etc/rc3.d/S15nfs.server
    /etc/rc3.d/S21rfs

    If your script is named sybstart, enter:

    ln /etc/init.d/sybstart /etc/rc3.d/S77sybstart

    In this example, you can use any number greater than 27 in place of 77.

For Linux:

You can perform an ls command on the rc directory to view existing sequence numbers. For example:

ls /etc rc5.d/S*

returns:

/etc/rc5.d/S12syslog
/etc/rc5.d/S14nfslock
/etc/rc5.d/S27ypbind

and so on. If your script is named sybstart, enter:

ln -s /etc/init.d/sybstart    /etc/rc5.d/S99sybstart

In this example, you can use any number greater than 27 in place of 99.