Cron job not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cron job not working
# 1  
Old 03-09-2004
Question Cron job not working

Hi All,

I created a shell script and it works perfectly fine when I run from the command. But the same does not work as expected when I call it from a cron job.

Here is the shell script(scan.sh):

#
#
#Which directory to scan for files?
SCANDIR="/cmb/data/exstream/mbui/mb_requests/templeton/";

#which is the working directory?
WORKDIR="/cmb/data/exstream/temp/"

#Which directory to place the processed files?
ARCHIVEDIR="/cmb/data/exstream/mbui/mb_requests/processed/templeton/";

#How does the processed file differ?
DIFFERSBY="_";

#Log all operations
LOGFILE="/cmb/data/exstream/scriptslogs/scan.log";

#Call Engine
ENGINECMD="/cmb/apps/dialogue/Engine -CONTROLFILE=/cmb/data/exstream/meetingbooks/mbui_control_test.txt -FILEMAP=MB_UIOPTIONS,/cmb/data/exstream/temp/"

cd $SCANDIR
for FILE in * ; do
FILENAME=$FILE
NEW=$ARCHIVEDIR$DIFFERSBY$FILENAME
cp $FILE $WORKDIR$FILE
$ENGINECMD$FILENAME
cp $WORKDIR$FILE "$NEW"
echo $ENGINECMD$FILENAME
echo "$FILE Processed and moved to Archive" >> $LOGFILE
done

And, Here is the CRONTAB entry:

1 * * * * /usr/bin/sh /cmb/data/exstream/scriptslogs/scan.sh

I am not sure if I am missing something here. Looks like the cron job is running, since it sends a failure mail if I remove the scan.sh from the path.

Please advise and Thanks All in advance for your help!!

Regards
Jana
# 2  
Old 03-09-2004
use the shebang syntax on the first line of your script

#!<path to shell>


it also helps to know what error you are getting in your cron job.
# 3  
Old 03-09-2004
Hi,
Thanks for the response. I tried adding the line
#!/usr/bin/sh in the shell script, but still my CRONJOB seems to be not working.
Is there anything else that I should look at!
Thanks
Jana
# 4  
Old 03-09-2004
as i posted earlier what is the error you are getting?
# 5  
Old 03-09-2004
Hi Optimus_P,

I want the CRONTAB to run once a minute, but it takes a while may be around 15 minutes or so to start the job. And the error in mail is given below.

///////////////////////////////////////
/cmb/apps/dialogue/Engine -CONTROLFILE=/cmb/data/exstream/meetingbooks/mbui_cont
rol_test.txt -FILEMAP=MB_UIOPTIONS,/cmb/data/exstream/temp/mb_395.csv
ld.so.1: /cmb/apps/dialogue/Engine: fatal: libodbc.so: open failed: No such file
or directory
Killed
/////////////////////////////////////////

It says No such file or directory, but actually the directory is available.
Please advice!
Thanks
Jana

Last edited by janavenki; 03-09-2004 at 07:22 PM..
# 6  
Old 03-09-2004
Just at a glance, it looks like "libodbc.so" can't be found by the program. If you type "env" from your shell (or the one that's running this script manually), do you see a LIBPATH or similar variable? You may need to add that to the script.

It's always a good idea to duplicate a manual run and a scheduled run as closely as possible. Same directory, same variables, same syntax, etc.
# 7  
Old 03-10-2004
most problems like this one come from cron not haveing the proper env settings.

try getting into the habbit of sourceing an env profile or declaring all the env settings you will need.

you need to add them to this path:
LD_LIBRARY_PATH

Library paths goto : LD_LIBRARY_PATH

ie: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path to the missing library.>


useing cron to start a job every minute is not wise. you will run into alot of problems and you are setting yourself up for a race condition.

if you require your application to run every minute then i would look into running it from inittab.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Crontab - entry not working , cron job not running

I have put a cron entry in oracle user for taking hot backup every wednesday@ 2.30 AM and have given the cron entry 30 02 * * 3 /u01/vijay/hotbackupcron 2>&1 >> /u01/vijay/hotbackup.log also find below the script inside hotbackupcron, i have put in env variables as well ... (13 Replies)
Discussion started by: vijaymec50
13 Replies

3. AIX

Cron job not working but works on other nodes.

Hi All, I have a many cron jobs scheduled in my AIX server. Only one cron not getting executed in the same server but that job is good on all other servers. Here is my cron , which will keep last 30 files and remove others., 00 00 * * * /usr/bin/find /tmp/reports/nmon -name *.nmon -mtime... (9 Replies)
Discussion started by: Thala
9 Replies

4. UNIX for Dummies Questions & Answers

Cron job not working

cron process in AIX is there when I do ps -ef |grep cron, but none of cron job is working. It appears that cron process is hanging or having some issues? How do you resolve this? Do I kill the cron process by kill -9 PID? and how to start it? Please advise. (1 Reply)
Discussion started by: Daniel Gate
1 Replies

5. Shell Programming and Scripting

Cron job is not working in the desired manner on IBM AIX

Hi, I have created a cron job on IBM AIX but it is not working in desired manner ! Here are the steps which I have followed :- #!/bin/ksh #------------------------------------------------------------------ find /some/file/at/the/user/side/test.log -exec cp {}... (8 Replies)
Discussion started by: acidburn_007
8 Replies

6. Shell Programming and Scripting

cron job now working?

Hi all, I wrote a script as below, #!/bin/ksh . /app/home/etc/sudo.profile >/dev/null java -jar $HOME/abc.jar The jar file abc.jar is located in the same folder as the script. When I'm manually running that script the jar file gets executed. However if I set a cron job, it... (5 Replies)
Discussion started by: isaacniu
5 Replies

7. Shell Programming and Scripting

cron job is not working for two scripts

Hi Gurus, I have a test unix server in which currently some unix cronjob are running. I have written two script one is a shell script in which env variable are there (in that i am exporting those variables). I have also written a perl script . when i am running at the shell manually like... (5 Replies)
Discussion started by: sanjay.login
5 Replies

8. Shell Programming and Scripting

Sudo command not working with cron job.

Hello, I have written a script that has a sudo command to change file permissions within it. When I run the script manually, the sudo command inside of it works fine. When the script is run through crontab I get the error "cron: not found". It the same user profile that I am using... (6 Replies)
Discussion started by: WhotheWhat
6 Replies

9. Shell Programming and Scripting

cron job not working for some reasons

I set up a new cron job. I have set cron jobs many times in the past and never faced issues. For some reasons my new cron job is not working.This is how my cron job looks like. plz help me out guys. 3,8,13,18,23,28,33,38,43,48,53,58 * * * * /siebel/sblp900/home/FSMTaskChk/script... (14 Replies)
Discussion started by: ragha81
14 Replies

10. UNIX for Dummies Questions & Answers

Cron job not working

Hello, I have the following crontab entry that does not seem to be running. When I check /var/cron/log, it is not there. Here is my os info: SunOS birch 5.9 Generic_118558-09 sun4u sparc SUNW,Sun-Fire-V240 Here is the crontab entry: 01 21 * * * find /export/app/datafeed/flus/archive -mtime... (5 Replies)
Discussion started by: dkranes
5 Replies
Login or Register to Ask a Question