Operating System - HP-UX
1851744 Members
2718 Online
104062 Solutions
New Discussion

"if" cron entries under MC / Service Guard

 
SOLVED
Go to solution
Victor Makukha
Advisor

"if" cron entries under MC / Service Guard

Hi Ladies and Gentlemen,

I have 2-node cluster with common EVA storage and these nodes have identical crons with the lines like:

# Run the Log Rollover utility each night
0 0 * * * [ -d /apps/cron_APP ] && APP_DIR=/apps/inst2/app;export APP_DIR;APP_DIR/bin/startlogroll >> $APP_DIR/logs/logroll.log 2>&1

where /apps is a filesystem mounted by SG and cron_APP is a dir created specially for this "if" construction. But nevertheless the mail of the cron owner is plugged with the messages like:

***
Subject: cron
Content-Length: 366
Status: RO

sh: /logs/logroll.log: Cannot create the specified file.


*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

[ -d /apps/cron_APP ] && APP_DIR=/apps/inst2/app;export APP_DIR;APP_DIR/bin/startlogroll >> $APP_DIR/logs/logroll.log 2>&1

I receive this messages on the node where the /apps filesystem is UNMOUNTED, so the part after && should not be executed at all, but cron tries to execute it anyway...
What could be wrong?
Master
5 REPLIES 5
Oviwan
Honored Contributor

Re: "if" cron entries under MC / Service Guard

James R. Ferguson
Acclaimed Contributor
Solution

Re: "if" cron entries under MC / Service Guard

Hi:

The semicolon before the 'export' terminates the conditional nature. I think you want something like this:

[ -d /apps/cron_APP ] && { APP_DIR=/apps/inst2/app;export APP_DIR;APP_DIR/bin/st
artlogroll >> $APP_DIR/logs/logroll.log 2>&1; }

Note the semicolon at the end of the sequence before the closing curly brace.

Regards!

...JRF...
spex
Honored Contributor

Re: "if" cron entries under MC / Service Guard

Hi,

Three comments:

1) Check if /apps/cron_APP exists as a directory on the root filesystem. If it does, [ -d /apps/cron_APP ] would return 1.

2) I don't see why you need to perform variable substitution here. Just use explicit references to $APP_DIR:
0 0 * * * [ -d /apps/cron_APP ] && /apps/inst2/bin/startlogroll >> /apps/inst2/app/logs/logroll.log 2>&1

3) You have an error in your crontab entry:
...APP_DIR/bin/startlogroll...
should be:
...$APP_DIR/bin/start/logroll...

PCS
Victor Makukha
Advisor

Re: "if" cron entries under MC / Service Guard

2 James:
Thanks very much, that's what I needed indeed. I corrected the crontab and I'll check tomorrow if the logs are OK.

2 Spex:
As far as I know test [ -d ... ] statement returns 0 if the statement is true and 1 if it does not find anyting...
Master
Victor Makukha
Advisor

Re: "if" cron entries under MC / Service Guard

Yyyes, I'd checked, it works!
Master