Help my crontab

Hello,

I believe something is wrong with my crontab.

I have a script that executes just fine from the console (manually executed). If I put that bad boy into cron it gives me the following errors:

sr1> tail /usr/spool/mail/user
exec(): 0509-036 Cannot load program /usr/local/bin/getlogical because of the following errors:
        0509-150   Dependent module libclntsh.a(shr.o) could not be loaded.
        0509-022 Cannot load module libclntsh.a(shr.o).
        0509-026 System error: A file or directory in the path name does not exist.

Also, cron is configured to send the output to a log file, but it's writing the name funny.

Here's the cron entry

34 15 * * * /dir1/script.sh > /dir1/log/script_`date +%Y%m%d`.log 2>&1

Here's the log name output

script_Tue Apr 23 15:34:03 EDT 2013

What's up with this?

With nearly 300 posts you should know the routine: show us. Don't tell us about the script - show us. My guess is that you are falling for the Cron Problem Number One, but to verify i am right or wrong would mean taking a look at your scripts code.

I guess your problem with the wrong date-format comes from the same source. Your environment probably has a different LOCALE set than your init process and without a PATH variable set correctly i wonder what is in fact executed as "date".

I hope this helps.

bakunin

That does help.

I made some changes to the way the entry is in cron to this:

30 22 * * * [ -f /home/test/users/user/.profile ] && . /home/test/users/user/.profile && /dir1/script.sh > /dir1/log/script_`date +%Y%m%d`.log 2>&1

Now I'm getting:

The java class is not found: com/somedir/export/ExportUtil

Which is strange because the file indeed exist and with proper permissions. There's something strange with the way this environment is configured and I can't figure it out.

---------- Post updated at 11:55 PM ---------- Previous update was at 10:40 PM ----------

I managed to get the log file to come out properly by changing the date parameter from:

`date +%Y%m%d`.log 2>&1

to this:

$(date +\%Y\%m\%d).log 2>&1

Now if I can figure out what's wrong with the environment ... :rolleyes:

try executing the command
set
to a file, and then inserting it into your cron job. That should also include any environment information you have that is coming via the system.

p.s. I put system wide environment variables, as much as possible in /etc/environment . Others (that require shell assistance aka scripting) I put into /etc/profile - goal is to not need (actually forbid) the use of .profile, .login, etc..

cron treats % specially - a crappy feature IMHO.
It must be escaped \% and this is visible by the program. The program should be a shell that converts \% back to %
For example
date '+%d' or date '+\%d' do not work, but date +\%d is treated by the shell.