-   Linux - Server (
-   -   Cron job fails (

kushanx 04-07-2010 09:47 AM

Cron job fails
Hi Experts,

We have an issue and need some expert advise. In one of the linux servers, we are running some cron jobs. This cron job loads flat files in to a table in a oracle database using a shell script. This was working fine. Recently we did an upgrade to kernel version and after that it loads the data half way and stops the cron job. (e.g. if there are 100 files, it loads about 13 files and stops). No error anywhere. Assuming that error is due to the kernerl issue we reversed the patch also. But still the problem is still there.

When you execute the file upload shell script manually then it works fine.

This is the OS details of the server

OS name: Red Hat Enterprise Linux ES release 4 (Nahant Update 6)

Kernel version: kernel-smp-2.6.9-89.0.23.EL

Current Kernel version: Linux CCOLDWHZDBOP01 2.6.9-89.0.23.ELsmp #1 SMP Fri Mar 5 17:56:21 EST 2010 i686 i686 i386 GNU/Linux

Thanks a lot in advance.

Best Regards

mreschke 04-07-2010 09:50 AM

If a cron job works fine manually, but not from cron, its usually because the path and environment variables are different when run by cron. Example, if a script uses tar, and tar is in your normal users path, then the script will work fine when run manually by that user. If tar is not in crons path, cron will not find tar and the script will fail when run automatically by cron. The update might have changed the way cron handles it's path and env variables. Something to investigate.

mreschke 04-07-2010 09:54 AM

If the script you use only has one command, then this cron/path/env would probably not be the issue since it obviously found the command for at least 13 rows. If your script is long, and it inserts records at different places in the script, then the script is probably using some command not found in crons path.

kushanx 04-07-2010 09:55 AM

Hi mreschke,

Thanks a lot for the reply.

Its not that cron does not run at all. It uploads few files from the list and then stops. No errors on any logs. As i have mentioned above if i submit 100 files it uploads few like 13 - 15. When you run the same scrip in command prompt it uploads all 100 files.

So it cant be an environment variable since it's able to execute half way isn't it ?

Thanks and Regards

kushanx 04-07-2010 10:00 AM

Also text files use for the upload are almost similar. We even changed the files and tried but still it could upload only few when executing though the cron.

Best regards

kschmitt 04-07-2010 11:13 AM

Are you logging inside the job, and are you redirecting the jobs output someplace useful?

Read through your output, read through your system logs from that same time-period.

Are the jobs being run as root, as your user, as another user?

If it dies halfway through we need a lot more information to diagnose it :)

Fingers of Fudge 04-07-2010 11:24 AM

Is it the first 13 or so files, or is it a few from here and a few from there?

kushanx 04-07-2010 01:09 PM

Thanks for all your replies.

As far as I can see, always the first few files upload successfully though the cron job.

But when I execute the script manualy all the files get uploaded without any issues.

Thanks a lot in advance.

mreschke 04-08-2010 10:46 AM

really just need more info, maybe we could see your script?

Randeep 04-09-2010 01:05 AM

Easy steps for scheduling through cron

All times are GMT -5. The time now is 10:23 PM.