The oratab usage comment is not correct… or it’s a bug in dbstart/dbshut (sort of)…

I’m talking about the ‘third’ field in the database entries. Field number three. Which indicates there could be a fourth, fifth etc… right?

A customer where I came (who went from AIX to Linux), who had interpreted this comment and therefore expanded the oratab with an extra column, to datapump the database (y/n).

When I shut down the databases, there was some unexpected behaviour when I invoked dbshut… Strange, but the extra (last) field ‘for datapump’ was read, not the third!

From oratab file:

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
# Entries are of the form:
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.

The entries ‘of the form’ also ends with a colon, something I did noticed before, but never used.

From the dbshut script (dbstart is similar):

# This script will shutdown all databases listed in the oratab file
# whose third field is a "Y" or "W".  If the third field is set to "Y" and
# there is no ORACLE_SID for an entry (the first field is a *),
# then this script will ignore that entry.


# To configure, update ORATAB with Instances that need to be shutdown
#    Entries are of the form:

Again, the entries ‘of the form’ ends with a colon…

BUT… in the dbshut script, where the entries are looped:

# Loop for every entry in oratab file and and try to shut down
# that ORACLE
# Following loop shuts down 'Database Instance[s]' with 'Y' entry

  # Proceed only if last field is 'Y' or 'W'
  if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then

There is this {print $NF} in awk… it means returning the LAST field (or a bit more precise: The number of fields in the current input record)! Is this where the bug is?

Should this be changed to {print $3}, the third field or should all the comments be corrected to say ‘last field’ or should we need to stay away from (mis)using the oratab…?!

The customer now is using the ‘third’ field for their ‘(datapump the db y/n)’. The last field is defaultly used to stop/start the database.

Be careful, happy shutting!

Tagged , . Bookmark the permalink.

5 Responses to The oratab usage comment is not correct… or it’s a bug in dbstart/dbshut (sort of)…

Leave a Reply

Your email address will not be published. Required fields are marked *