creating correct init.d scripts

Posted on 2005-05-09
Last Modified: 2013-12-16
I'm trying to create a startup script for an Oracle AS mid-tier. It waits for the existence of an ldap on another server (using wget), then starts Oracle's opmn which starts several daemons, then starts Oracle's emctl which starts yet other processes.

I have several questions.

1) what are the minimum set of commands that should be in my script start,stop,status,restart etc?

2) where do the logs for inits usually go, and how do I correctly write to a syslog? The whole syslog thing has me confused...

3) The "wait" for the other server is done using "start &" in order to not block the startup. Is this right, or is this redundant as init does something like this already?

Using RHES3.
Question by:rkogelhe
    LVL 40

    Accepted Solution

    The minimum set of commands that an init script is required to have is start & stop. Any others (restart, status, etc., are discretionary.

    There are no standard logs for init scripts. You can send messages to syslog via the logger command (see 'man logger').

    Used in-line in the script wget will block further execution of the script until it succeeds or times out. So simply checking the status of the wget  command would be the correct approach. If the wget fails you should exit out of the script (with an informative error message).
    LVL 3

    Author Comment

    Thanks for your answer.

    For (2), I should capture the output of the Oracle commands and then user logger to log them with something like

    opmnctl startall | while read line
      logger -s -t OPMNCTL -p local0.notice $line

    but then what happens to the message? How does syslogd interpret it? Why is there a -f option? Shouldn't syslog manage that?

    For (3), I'm currently using a wget + sleep loop until wget returns 0. the entire start() is called with start &. But if I had not called with &, would the start() have blocked the entire init?

    Is there a good description of how logger and syslogd and syslog.conf work together somewhere?
    LVL 3

    Author Comment

    I wonder as well if there is a way to use tee with logger to capture everything in the script...
    LVL 3

    Author Comment

    Just to update with respect to my last comment: to get logger to capture everything, create a script

      exe=`/bin/basename $1`
      test -z "$tag" && tag=$exe
      test -z "$pri" && pri=user.notice
      /usr/bin/logger -i -t ocmp.logger -p $pri "Will log $exe std & err output as $tag"
      /usr/bin/logger -i -t ocmp.logger -p $pri "Executing \"$*\" as `/usr/bin/id -un`..."
      exec $* 2>&1 | /usr/bin/logger -i -t $tag -p $pri

    Then use this script to call the final script and put just

      /bin/ /home/user/bin/


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
    SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now