1752703 Members
5449 Online
108789 Solutions
New Discussion юеВ

Re: Script problem

 
Sanjiv Sharma_1
Honored Contributor

Script problem

Hi,
I have written a small script with files permission (777) and root:sys as owner:group which collects the list of sessions of Omniback for the last 24 hours and send me an emal. This is running through cron at 8:30 am.

It has been observed that I receive an email of blank text. But when I run it manually it send me proper report in the text.

Script attached.

What is the problem? What needs to be checked?

Thanks,
Raje.
Everything is possible
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: Script problem

Hi:

This one is easy; you are a victim of cron's intentionally sparse environment.

You need to add these lines lines to your script:

PATH=${PATH}:/opt/omni/bin:/opt/omni/lbin
export PATH

I would also have this script generate a temp file name rather than using a hard-coded name; that's generally considered bad form.

e.g.
TDIR=${TMPDIR:-/var/tmp}
PIS=${$}
T1=${TDIR}/X${PID}_1.txt

You then direct omnirpt's stdout to ${T1} and your mail commands stdin is ${T1}. After the mail, you do a rm -d ${T1} to delete the file.
If it ain't broke, I can fix that.
V. V. Ravi Kumar_1
Respected Contributor

Re: Script problem

hi,

set ur path as Clay suggested or in your crontab include some thing like this.

0 * * * * sh

regds
Never Say No
MANOJ SRIVASTAVA
Honored Contributor

Re: Script problem

Hi

Either the PATH or just put the following :

#!/usr/bin/sh

admin1=raje@abc.com


/opt/omni/bin/omnirpt -report list_sessions -timeframe 24 24 > /ss/omnirpt.txt

mailx -s "List of Omnibackup Sessions for the last 24 hours" $admin1 < /ss/omnirpt.txt



also you can star the script wiht !/usr/bin/sh -x in debug mode and find out the error in the mail of root if the script fails.


Manoj Srivastava