Operating System - HP-UX
1752576 Members
4425 Online
108788 Solutions
New Discussion юеВ

Re: Cronjob not running even in log showed the activities

 
SOLVED
Go to solution
Avinash20
Honored Contributor

Re: Cronjob not running even in log showed the activities

The best way to troubleshoot the issue is to redirect the output, to check where the script fails

eg:
0,5 * * * * su - express -c "/home/express/BIN/edi_session.sh CODECO_MSK" >> /tmp/CODECO_MSK.out

Then you could check /tmp/CODECO_MSK.out to find out where it fails

Good Luck !!

"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Patrick Wallek
Honored Contributor

Re: Cronjob not running even in log showed the activities

Whose crontab are these jobs running from? Are they running from root or are they runnign from the 'express' user?

Your 'crontab -l' in your last post appears to have been run from the 'express' user.

If they are running as 'express' then your problem is likely the 'su - express' that you are doing.

The only user that will allow the 'su - express -c' syntax to work WITHOUT requesting a password is root.

If you are logged in as express and you try to 'su - express' then you will get prompted for a password. That is probably where your jobs are failing.

If this is really the crontab for the express user then omit the 'su - express -c' from the beginning of each line, and omit the quotes, so that they look like:

0,5 * * * * /home/express/BIN/edi_session.sh CODECO_MSK
0,5 * * * * /home/express/BIN/edi_session.sh CODECO_APL
0,5 * * * * /home/express/BIN/edi_session.sh COARRI_MSK
0,5 * * * * /home/express/BIN/edi_session.sh COARRI_APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK


AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

crontab running from user express.

this is my orginal crontab file which fail in the fist place

Crontab file
#TO RUN AND PROCESS BAPLIE EXTRACTION FOR MSK
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK

#TO RUN AND PROCESS BAPLIE EXTRACTION FOR APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL

#TO RUN AND PROCESS CODECO EXTRACTION FOR MSK
0,30 * * * * /home/express/BIN/edi_session.sh CODECO_MSK

#TO RUN AND PROCESS CODECO EXTRACTION FOR APL
0,30 * * * * /home/express/BIN/edi_session.sh CODECO_APL

#TO RUN AND PROCESS COARRI EXTRACTION FOR MSK
0,30 * * * * /home/express/BIN/edi_session.sh COARRI_MSK

#TO RUN AND PROCESS COARRI EXTRACTION FOR APL
0,30 * * * * /home/express/BIN/edi_session.sh COARRI_APL
Avinash20
Honored Contributor

Re: Cronjob not running even in log showed the activities

Could you run the cron jobs one at a time.
Let see where it fails
Instead of redirectly the output to /dev/null, please redirect it to a particular file which will allow us to know where it gets failed

Also from the post I could see the the cron logs shows that the script is completed sucessfully

CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK > /dev/null
> express 26722 c Tue Jan 13 11:22:00 WAT 2009
< express 26722 c Tue Jan 13 11:22:01 WAT 2009

Please correct me ..

The above menthod of redirecting the output to some specific file will exactly let you know how the script goes ..

eg:

* * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK > /tmp/BAPIN_MSK.out

Check BAPIN_MSK.out and check if that is what the output your required.
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
OldSchool
Honored Contributor

Re: Cronjob not running even in log showed the activities

"home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK"

1) fix one at a time...what fixes one will probably fix the others
2) since you're trying to run them as "express" is "express" *allowed* to run cronjobs? check cron.allow
3) in the above, is this *one* job with *three* parms? It looks like it is supposed to be *2* jobs with *2* parms each
4) as noted before...are all the correct environment variables that are needed set within the script. cron strips the environment way down.
5) do any of the above work from the command line, and if so, what *exactly* do you enter?
sujit kumar singh
Honored Contributor

Re: Cronjob not running even in log showed the activities

Hi

yes as oldschool says that , try using the changes that u make on one of the commands only, if that is successful that means that rest are successful.

also from logs it seems that ur cron is able to create the jobs successfully.

try rediredting the O/Ps to some file and see the O/p of those files.

if u want to use -c option as i had said earlier, try running the jobs as root.

also can for one of the commands try to redirect the O/P to some file and compare that O/P with what u get on the screen when u execute the command from the command line.\
This will help u know the difference if that command is running as a cron then where it stops (.... if that stops) as compared to runniug from the commsnd line.

try posting the O/P for an individual command as run from the command line.

Regards
Sujit
Dennis Handly
Acclaimed Contributor

Re: Cronjob not running even in log showed the activities

>I've made a changes as below but cronjob still not running
> CMD: su - express -c "/home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK"
> express 5184 c Tue Jan 13 17:22:00 WAT 2009
< express 5184 c Tue Jan 13 17:22:02 WAT 2009 rc=9

Something is running and got an return code of 9. Probably do to that su that Patrick mentioned.
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

ok..i take ur advise.

i had changed my cronjob for one task for the test

bahora1(express)$ crontab -l

#TO RUN AND PROCESS BAPLIE EXTRACTION FOR APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL > /home/express/tmp2/BAPIN_APL.out

output from BAPIN_APL.out

Processing /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/636942.EDI
/home/express/BIN/edi_load_post.sh BAPIN_APL /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/636942.EDI
Processing /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi
/home/express/BIN/edi_load_post.sh BAPIN_APL /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi

From the file i can't find any error and seem like conjob is running.The only thing is the command not do anything to our application.To be more specific, we are using cronjob as a schedule job to grap edi file sended by our customer and extract all edi information to our application.

i do a test by manually run the command and it's work to our application

bahora1(express)$ /home/express/BIN/edi_load_post.sh BAPIN_APL /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/636942.EDI

crosscheck cron.allow

# cat cron.allow
root
adm
uucp
express
oracle

"express" user is there.

It's quit weird the command from cronjob not effect ou application.Any idea?






Elmar P. Kolkman
Honored Contributor

Re: Cronjob not running even in log showed the activities

Since the command runs from the commandline and not from cron, there are two things to make sure first when the script runs:

The current working directory and the contents of the PATH environment variable.

Try adding the PATH environment variable to the script as the first command (open with vi, go to line 2 (line 1 should read something like #!/usr/bin/sh) and do:
:!set | grep PATH

Close the script.
If that doesn't help, doing a pwd command in the script also helps. But only when you don't redirect anymore to /dev/null. Or have the script itself log.
Every problem has at least one solution. Only some solutions are harder to find.
Avinash20
Honored Contributor

Re: Cronjob not running even in log showed the activities

Also with the above options also add the below line to
/home/express/BIN/edi_load_post.sh

set -x <<--= Add this at the start of the script

This will allow us the know how the script runs and offcourse you need to redirect the output as you are doing

Also the script needs to be more interactive saying what exatly it does

Good Luck !
"Light travels faster than sound. That's why some people appear bright until you hear them speak."