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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange Crontab behaviour

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
DE
Hi folks,

we noticed a strange crontab behaviour that's quite critical for us.

We have an entry there running a script "checkredo" every 5 minutes.

The script contains among others the following line:

su - $BPW_DB2ADM -c "db2diag -t $DATUM -gi \"proc := db2logmgr\"|grep LEVEL:"|grep Error > /tmp/redosave.log

Currently there ARE errors shown in the db2diag so the file /tmp/redosave.log should contain some entries after the script has been run ...

But if we run the checkredo the redosave.log is empty !
If we run the command

"su - $BPW_DB2ADM -c "db2diag -t $DATUM -gi \"proc := db2logmgr\"|grep LEVEL:"|grep Error > /tmp/redosicherung.log"

from command line (without cron or at involved) we HAVE entries in the redosave.log

We're getting absolutely no error from cron ...

Any idea what might be wrong here ??

Regards
Thomas
 
Hi Thomas,

Firstly is this entry recently added to your cron.
If this entry has been there for a long time, did you see it working before.

My strong feeling is that may be you are not redirecting the std input,std output and std err correctly in your crontab entry.

If you can paste your cron entry, this might give us some clues.

Cheers


 
You may want to try >> instead of >

Also a 2>&1 may help at the end of the syntax line in your cron entry.
 
crontab entry is

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/checkredo > /tmp/cronlog 2> /tmp/cronlog2

 
Any clues in /tmp/cronlog or cronlog2?

Perhaps a permissions problem?

Try this modification:

...
touch /tmp/redosave.log
chown $BPW_DB2ADM /tmp/redosave.log
su - $BPW_DB2ADM ...whatever... >/tmp/redosave.log
...


HTH,

p5wizard
 
If we run the command

"su - $BPW_DB2ADM -c "db2diag -t $DATUM -gi \"proc := db2logmgr\"|grep LEVEL:"|grep Error > /tmp/redosicherung.log"

from command line (without cron or at involved) we HAVE entries in the redosave.log
The usual reason for jobs which run fine from the command line failing from cron is that cron jobs do not have the complete environment.
Try adding
Code:
. /etc/profile
. ~/.profile
to the start of /usr/local/bin/checkredo

Ceci n'est pas une signature
Columb Healy
 
Try this as well:

su - $BPW_DB2ADM -c "db2diag -t $DATUM -gi \"proc := db2logmgr\"|grep LEVEL:"|grep Error > /tmp/redosave.log 2>&1

This will make sure that the errors will go to redosave.log as well!

Regards,
Khalid
 
opps

missed the 1> /tmp/redosave.log 2>&1

Regards,
Khalid
 
Hi folks,

we found the problem !

It was a special db2diag bevahiour under crontab we were unaware of and we had to include a "-readfile" behind the db2diag command ...

Now it's working.

Regards
Thomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top