• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

creating correct init.d scripts

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.
  • 3
1 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).
rkogelheAuthor Commented:
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?
rkogelheAuthor Commented:
I wonder as well if there is a way to use tee with logger to capture everything in the script...
rkogelheAuthor Commented:
Just to update with respect to my last comment: to get logger to capture everything, create a script loginit.sh:

  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/loginit.sh /home/user/bin/myinitscript.sh

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now