Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron error messages

Status
Not open for further replies.

aego

Technical User
Aug 29, 2001
30
NL
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 &quot;+day=%d; monthnum=%m; year=%Y&quot;`
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
 
does messages say anything?

did you try manually running as root with its env variables? (su - root as opposed to su root)
 
Don't forget that a cron job when it logs in does not
have any environment set, you will need to do this at the
start of the script. For example, it executes fw, but the
PATH probably isn't set. If let's say, your environment
settings are in the .profile of the home directory, then
you could do:
. ./.profile
to make sure the .profile is read at the start to setup
the required PATH entries and any other environment settings
that are required.
Good luck John Philcox
Mobile Ventures Limited UK
 
This is a fairly common question. See thread60-83479 for one possible solution (the final thread entry). Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top