1827238 Members
2251 Online
109716 Solutions
New Discussion

cron settings

 
mtang
Occasional Contributor

cron settings

Hi,

I want to submit scripts by cron and make it run automatically. I check cron log , there is no error, but the script doesn't run. I don't why. below is the log
> CMD: /opt/mfgpro/eB2/localsp7/bin/daily2.batch 1> /tmp/cron/eb2.log 2>>&1
> mfg 4167 c Tue Jul 5 08:35:00 EAT 2005
< mfg 4167 c Tue Jul 5 08:35:00 EAT 2005 rc=2
7 REPLIES 7
Ermin Borovac
Honored Contributor

Re: cron settings

Try changing

/opt/mfgpro/eB2/localsp7/bin/daily2.batch 1> /tmp/cron/eb2.log 2>>&1

to

/opt/mfgpro/eB2/localsp7/bin/daily2.batch 1> /tmp/cron/eb2.log 2>&1

(only one greater than sign)

Sudeesh
Respected Contributor

Re: cron settings

Are you checking the cron log file or /tmp/cron/eb2.log file?
I see from the cron command line above, output from your cron job is redirected to /tmp/cron/eb2.log file. Check this file for any errors.


Sudeesh
The most predictable thing in life is its unpredictability
Vibhor Kumar Agarwal
Esteemed Contributor

Re: cron settings

Is your script running without cron. ;-) Just kidding.

Make sure any other application is not using the file in which you are redirecting the output. If this happens your cron will stop.
You can check this by fuser.
Vibhor Kumar Agarwal
Kasper Hedensted
Trusted Contributor

Re: cron settings

Also if your script refers to other commands, make sure that you use absolute or relative path to the script/command (or setup the PATH variable within the script).
The PATH environment variable is only containing "/usr/bin:/usr/sbin:." when run from cron.
Cheryl Griffin
Honored Contributor

Re: cron settings

There was an error - it was just not obvious:
< mfg 4167 c Tue Jul 5 08:35:00 EAT 2005 rc=2 <--- rc = return code, 2 means the cron job failed. 0 would indicate it's successful.

Run your script outside of cron, if it is not successful, there is a script problem. If it is successful, but within cron it fails, it means that your script is lacking some environment variable.

Cron runs in a pseudo environment:
When you login, the .profile and /etc/profile are sourced which sets the necessary environment variables.

In cron these are not set because there is no associated login so you must set any required variables within the script itself.

"Downtime is a Crime."
Pete Randall
Outstanding Contributor

Re: cron settings

Just to add to Cheryl's response - among the environment variables that won't be set is your PATH, so be sure to either set your path or use full path names in your script.


Pete

Pete
G V R Shankar
Valued Contributor

Re: cron settings

Hi,
Let me try to isolate the problem.

1. check whether the cron daemon is running or not.

2. Just tell whether any other scripts are there along with this script.

3. if so do they run properly

4. If this is the only script in cron, please try to run a sample script and check whether it is running properly or not.

25 22 * * * touch /ABCDEF

if the above file is not created, please let me know.

Regards,

Ravi.