2006/12/04

more scripting fun

it's been a week of exercising my old shell scripting skills, this one...

well, picture this:

. someone installs a new test instance called "zot10".
. prior to this, there was a "zot" test instance there.
. a week later cron fires off the cold backup of "zot" .
. cold backup fails, complaining that there was a left-over process after shutdown still connected to the "zot10" instance!

WTH???

this is the command line that checks for "left-over" processes after shutdown:

ps -ef|grep "ora_pmon_$ORACLE_SID"|grep -v "grep"

followed by some suitable return code testing.

nothing wrong with it. on face value...

but the devil is always in the details: in HP boxes, the output of "ps" ends on the comand line string, with EOL after it.

but that is NOT what the above grep search string looked for. it looked for "ora_pmon_zot", period. *anywhere* in the output of ps.

you guessed it: "ora_pmon_zot" and "ora_pmon_zot10" all look the same to such a match string!

there was always a "left-over" process for "zot" for as long as there was a "zot10" instance running!

the fix was to make grep look for the CORRECT match string:

grep "ora_pmon_${ORACLE_SID}\$"

something else I always do: use the "{}" around variable names in shell scripting. I know: it's not needed in 99.9% of the cases.

it's the remaining 0.1% though that makes you leave bed at 3am to fix silly problems. I'm a strong believer in avoiding ALL possibility of problems, not just 99.9%. As such I use the "{}" around variable names ALL the time. Period.

'nyways: 'nuff shop-talk

not much done in the photo front: been very busy with parties, setting up the Xmas decos inside the house, etc. got three rolls to take to the lab this week, will scan them later. and I've got to start on my older underwater slides at some stage!

it's been pelting down for the whole weekend. to the point where our planned fishing trip had to be canceled!

bummer...

3 Comments:

Blogger Joel Garry said...

Yeah, even after all this time, not long ago I added a tenth parameter to a script and had:

...
LOC_8=$8
LOC_9=$9
LOC_10=$10
: ${LOC_1:="/oradata/exports/bla1"}
...
: ${LOC_10:="/oradata/exports/bla10"}
(for those who don't know, that means "if this variable is null, set it to the quoted value")
...
imp file=${LOC_10} ...

imp complains 0.dmp not found...
[blush]

Wednesday, December 06, 2006 11:51:00 am  
Blogger Noons said...

This comment has been removed by a blog administrator.

Wednesday, December 06, 2006 4:54:00 pm  
Blogger Joel Garry said...

I guess I'll be using the name Sy from now on :-)

Thursday, December 07, 2006 10:45:00 am  

Post a Comment

Links to this post:

Create a Link

<< Home