ksh(?)/cron error opening here document on /tmp

From: <Russ_Fish_at_idx.com>
Date: Fri, 07 Jan 2000 11:06:37 -0800

To: tru64-unix-managers
I have a cron job which is running some of the time but not all of the time.
I've included the entire script at the bottom of this msg. The cron is using
a here document to run an oracle select statement, and it's failing with the
following error (ksh -x output):

+ export PATH=/usr/bin:/usr/ccs/bin:/usr/sbin:/usr/local/bin
+ [[ -z srvname ]]
+ [[ -z testalias ]]
+ cut -d: -f1 /etc/oratab
+ grep -v ^#
+ grep -v ^\*
+ grep srvname
+ [[ -z srvname ]]
+ [[ ! -a /usr/users/oracle/.mailrc ]]
+ grep testalias /usr/users/oracle/.mailrc
+ [[ -z alias testalias some_admin_at_idx.com ]]
+ export ORACLE_SID=srvname
+ export ORACLE_HOME=/u01/app/oracle/product/7.3.4
+ export MAILRCP=testalias
+ + sed -e /^$/d
+ /u01/app/oracle/product/7.3.4/bin/sqlplus -s /
+ /usr/local/$admin/bin/chkfaileddbajobs[45]: /tmp/sh27954.2: cannot open <--
BADJOBS=

I cannot discern a pattern to the failures. Our /tmp directory gets a lot of
user writes
(application log files) and does not have quotas enabled, so I will add quotas
over
the weekend and run verify on the root domain. If anyone has other suggestions
on
resolving this issue, let me know (esp. if you've got a fix that lets me skip
the weekend
work :)).

Coding suggestions, sed/awk tricks, etc. are also welcome.

--Russ
----------
Russell C. Fish IDX Systems Corp.
Oracle DBA/Unix System Admin 1001 4th Ave. Suite 1500
PH: 206-689-1302 Seattle, WA 98154
mailto:russ_fish_at_idx.com

-------------- script follows -----------------------

#!/usr/bin/ksh
# check for jobs with nonzero failure count
# send email to $MAILRCP if found

# script path
export PATH=/usr/bin:/usr/ccs/bin:/usr/sbin:/usr/local/bin

# make sure instance name passed as input
if [[ -z $1 || -z $2 ]]; then
  print "usage: chkfaileddbajobs <instance> <mailalias>"
  exit 1
fi

# make sure instance is a legal one
if [[ -z $(cut -d':' -f1 /etc/oratab | grep -v "^#" | grep -v "^\*" | grep $1)
]]; then
  print "error: invalid instance $1 passed to $0"
  exit 1
fi

# make sure mail alias exists
if [[ (! -a ~/.mailrc) || -z $(grep $2 ~/.mailrc) ]]; then
  print "error: invalid mail alias $2 passed to $0"
  exit 1
fi

# Oracle setup
export ORACLE_SID=$1
export ORACLE_HOME=/u01/app/oracle/product/7.3.4

# alias is defined in ~/.mailrc
export MAILRCP=$2

# get info on failed jobs
# sed line removes blank lines
# note calling user must have 'OPS$' account & dba privs on instance
BADJOBS=$({
$ORACLE_HOME/bin/sqlplus -s / <<END
set heading off
select job, priv_user, what from dba_jobs where failures > 0;
exit
END
} | sed -e '/^$/d')

# if errors found, email/page the appropriate people
if [[ -n $BADJOBS ]]; then
    print $BADJOBS | sed -e 's/;/\
/' | mailx -s "URGENT: failed jobs in DBMS_JOB" $MAILRCP
fi
Received on Fri Jan 07 2000 - 19:09:34 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:40 NZDT