Startup Order for Sun Solaris w/ Respect to Script Execution

Posted on 2012-09-18
Last Modified: 2012-09-19
System info:

SunOS bartx041 5.10 Generic_147440-12 sun4u sparc SUNW,Sun-Fire-V490

What I need to know is the order solaris executes the various scripts that start things like oracle databases, etc., and the order in which scripts are executed on system shutdown and where they're located.

I see in /etc there is an init.d, but there are also rc<n>.d directories, where <n> is 0-6 and "S":

rc0 -> ../sbin/rc0*
rc1 -> ../sbin/rc1*
rc2 -> ../sbin/rc2*
rc3 -> ../sbin/rc3*
rc5 -> ../sbin/rc5*
rc6 -> ../sbin/rc6*
rcS -> ../sbin/rcS*

there are some "S" and "K" prefixed files in the rc<n>.d - one of the files looks to be the oracle database startup/shutdown - I guess what would help at this point is to understand the order that solaris executes the scripts in each of the init.d, rc<n>.d, etc.

Any help is as always appreciated.
Question by:dhite99

    Author Comment


    Here is what I see with respect to this oracle startup/shutdown script: There seem to be a lot of copies in these directories - if you could clue me in to what is going on with all of this, I would appreciate it.

    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    The rc#.d the # is the Unix run level.  They startup from 1 to whatever run level you specify.  The stop in reverse order.

    The S & K scripts are set up to 'S'tart and 'K'ill.  They should add up to be 999 or 900 ( I forget which) so the startup in one order and stop in the opposite order.  They are executed in order so for example if the S script is 001 the K script would be 998.
    LVL 23

    Expert Comment

    Do you understand the order in which the Oracle scripts are executed, and that RAC nodes require individual startups?
    LVL 76

    Assisted Solution

    Solaris 10 has legacy startup scripts which referenced, it also has startup process managed by svcadm manager.
    The legacy startup scripts are started based on the run level as pointed out.
    The runlevel is set in /etc/inittab
    3 is multi user non graphical mode, while run level 5 is multiuser graphical mode.

    The order is from S00 to S99 the scripts have to have execute bit set. When shutdown/restart the scripts are executed in the reverse order as pointed out earlier k99-k00

    In either case of using svcadm or legacy scripts, starting any service/application, you should configure it to start after any service, device on which it depends. I.e. a network dependent application should be somewhere I the higher S40s I think S40network
    At times applications, apache, MySQL, oracle, etc should be in the 80 and higher range to make sure everything is already up.

    To the other point, the K scripts will exist often in all levels going down from which the startup script is setup. This is to provide a mechanism for the system to shutdown services when the runlevel is reduced.
    I.e. you are in runlevel 3 and need to perform maintenance Solaris patch install, system cleanup, etc. you would on the console run init 1 to drop to single user.
    At this point most applications have to be terminated apache, oracle, MySQL, etc.
    The reduction to runlevel preserves the mount points that might not be if you reboot the system into single user.

    Once the maintenance is complete you can Raise it back

    Doing the same using svcadm can be seen at

    Author Comment

    Thanks all for comments -

    Arnold - couple of follow-on questions:

    Here is what is in /etc/inittab:

    # Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    # The /etc/inittab file controls the configuration of init(1M); for more
    # information refer to init(1M) and inittab(4).  It is no longer
    # necessary to edit inittab(4) directly; administrators should use the
    # Solaris Service Management Facility (SMF) to define services instead.
    # Refer to smf(5) and the System Administration Guide for more
    # information on SMF.
    # For modifying parameters passed to ttymon, use svccfg(1m) to modify
    # the SMF repository. For example:
    #       # svccfg
    #       svc:> select system/console-login
    #       svc:/system/console-login> setprop ttymon/terminal_type = "xterm"
    #       svc:/system/console-login> exit
    #ident  "@(#)inittab    1.41    04/12/14 SMI"
    ap::sysinit:/sbin/autopush -f /etc/iu.ap
    sp::sysinit:/sbin/soconfig -f /etc/sock2path
    smf::sysinit:/lib/svc/bin/svc.startd    >/dev/msglog 2<>/dev/msglog </dev/console
    p3:s1234:powerfail:/usr/sbin/shutdown -y -i5 -g0 >/dev/msglog 2<>/dev/msglog
    pt:s1234:powerfail:/usr/lib/svc/method/installupdates lock   

    Open in new window

    Can you identify what runlevel is set from the above? I cannot seem to see it.

    In addition, regarding the svcadm manager - how would I determine if that is being used and what it executes (if anything) in addition to the legacy startup scripts?


    Author Comment

    One other question - if I am reading the comment from slightwv  correctly, it executes all of the "S" prefixed scripts beginning at run level 1, then 2, then 3, and so on. This is to say that the "S" scripts get executed in all of the runlevels if the system is starting up. Is this correct, or does the runlevel get set to one single static number, and only those "S" scripts get executed on startup (for example, statically set the runlevel to 3, then only the scripts in RC3.d)?
    LVL 76

    Accepted Solution

    >>Can you identify what runlevel is set from the above? I cannot seem to see it.

    Looks like it is the 'default' for solaris since it isn't in there.

    Check out:

    >>or does the runlevel get set to one single static number

    Yes.  The server can only be running at a single run level.

    >>(for example, statically set the runlevel to 3, then only the scripts in RC3.d)?

    All rc.d folders UP TO run level 3 get executed in order:
    rc1.d form the lowest S number to the larges S number
    then rc2.d from the lowest to the largest
    then rc3.d from the lowest to the largest.

    On shutdown it goes in reverse order:
    rc3.d K scripts from the largest to lowest
    then rc2.d from largest to lowest
    then rc1.d larget to lowest.

    rc1.d has:

    rc2.d has:

    rc2.d has:

    The default runlevel is 3.

    Startup will run these in order:

    Shutdown in order:
    LVL 76

    Expert Comment

    The above only deals with the legacy scripts.
    A similar process exists within the newer service management system which are usually executed first.
    i.e. at runlevel1 svcadm based startup processes run, then the rc1.d, then runlevel2 and rc2.d and runlevel3 and rc3.d.

    svcs can be used to query the installed/status of apps/services

    To control runlevel on Solaris 10 uses smf.
    svcadm milestone -d milestone/single-user:default will change the default runlevel on boot to single user.

    Author Closing Comment

    Excellent information, explanation, & references.

    Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
    FreeBSD on EC2 FreeBSD ( is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
    Via a live example, show how to take different types of Oracle backups using RMAN.
    This video shows how to recover a database from a user managed backup

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now