Could anyone help me with this problem ?
I am trying to use cron to make my sysadmin work a bit easier by automating data-collection for the monthly security reports.
The whole process is partly based on a third-party ksh script. The script exports a daily switched FW-1 logfile, and converts it ( for reporting reasons ) to another format. It works fine from the command line, but as i try to schedule it, it fails on me. The cron log returns the following :
< root 4493 c Thu Feb 28 11:42:00 2002 rc=2
As i work with (ba)sh mostly, it leads me to think it has something to do with my environment settings. Could anyone tell me if this is true or what else could be wrong ?
This is my script:
#!/bin/ksh
# Script : fwdaily
# Version : 0.5
# Date : 27 feb 2002
# process Checkpoint FW-1 logfile
eval `date "+day=%d; monthnum=%m; year=%Y"`
day=$((day - 1))
if (( day == 0 )) ;then
monthnum=$((monthnum - 1))
if (( monthnum == 0 )) ;then
year=$((year - 1))
monthnum=12
fi
day=`cal $monthnum $year | awk '/[23]/{l=$NF} END{print l}'`
fi
month=`date +%b -d $monthnum`
yesterday=$day$month$year
yesternum=$day$monthnum$year
yesterfile=`ls -1 /opt/CPfw1-41/log | grep $yesterday | grep -w log`
cd /opt/CPfw1-41/log
fw logexport -i $yesterfile -o /export/home/fwlog/$yesterday.txt
unix2dos -ascii -iso -7 /export/home/fwlog/$yesterday.txt /export/home/fwlog/$yesternum.txt
rm /export/home/fwlog/$yesterday.txt
compress /export/home/fwlog/$yesternum.txt
I am trying to use cron to make my sysadmin work a bit easier by automating data-collection for the monthly security reports.
The whole process is partly based on a third-party ksh script. The script exports a daily switched FW-1 logfile, and converts it ( for reporting reasons ) to another format. It works fine from the command line, but as i try to schedule it, it fails on me. The cron log returns the following :
< root 4493 c Thu Feb 28 11:42:00 2002 rc=2
As i work with (ba)sh mostly, it leads me to think it has something to do with my environment settings. Could anyone tell me if this is true or what else could be wrong ?
This is my script:
#!/bin/ksh
# Script : fwdaily
# Version : 0.5
# Date : 27 feb 2002
# process Checkpoint FW-1 logfile
eval `date "+day=%d; monthnum=%m; year=%Y"`
day=$((day - 1))
if (( day == 0 )) ;then
monthnum=$((monthnum - 1))
if (( monthnum == 0 )) ;then
year=$((year - 1))
monthnum=12
fi
day=`cal $monthnum $year | awk '/[23]/{l=$NF} END{print l}'`
fi
month=`date +%b -d $monthnum`
yesterday=$day$month$year
yesternum=$day$monthnum$year
yesterfile=`ls -1 /opt/CPfw1-41/log | grep $yesterday | grep -w log`
cd /opt/CPfw1-41/log
fw logexport -i $yesterfile -o /export/home/fwlog/$yesterday.txt
unix2dos -ascii -iso -7 /export/home/fwlog/$yesterday.txt /export/home/fwlog/$yesternum.txt
rm /export/home/fwlog/$yesterday.txt
compress /export/home/fwlog/$yesternum.txt