[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


creating correct init.d scripts

Posted on 2005-05-09
Medium Priority
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
  • 3
LVL 40

Accepted Solution

jlevie earned 450 total points
ID: 13965294
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).

Author Comment

ID: 13966040
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?

Author Comment

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

Author Comment

ID: 14419638
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


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 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