1829540 Members
2974 Online
109992 Solutions
New Discussion

Crontab Issue

 
N Gopal
Frequent Advisor

Crontab Issue

Hi All,

Able to run custom script manually. But when scheduled through crontab it triggers the script but does not execute part of the script.
Scheduled crontab entry:
00,10,20,30,40,50 * * * * /usr/symology/syst/menus/runedis.scr

Thanks
8 REPLIES 8
Robert-Jan Goossens
Honored Contributor

Re: Crontab Issue

Hi,

Did you setup the PATH environment in your script?

Regards,
Robert-Jan
Anshumali
Esteemed Contributor

Re: Crontab Issue

Gopal,

the environment which user and cron uses are totally different. Cron uses a limited environment unless explicitly specified. Please put all the environment variables in the script or initialize the environment before the command itself. you may also try sourcing .profile of the user before the script.

Anshu
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
N Gopal
Frequent Advisor

Re: Crontab Issue

Robert,
Yes we have setup the PATH variables correctly as part of the runediu.scr script.

Anshu,
We have exported all the required environment variables before the actual script gets triggered. How do we shource hte .profile in the script?
Anshumali
Esteemed Contributor

Re: Crontab Issue

just execute the .profile in your script before anything else starts.
As only one part is not getting executed, can we log the O/P into some file with set -x enabled inside script?
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
N Gopal
Frequent Advisor

Re: Crontab Issue

We have executed the .profile and also included set -x but no luck. Infact, set -x is not outputting any log. Also .profile is outputting some junk characters.
Anshumali
Esteemed Contributor

Re: Crontab Issue

Have you tried the O/P logging via cron or inside script.

00,10,20,30,40,50 * * * * /usr/symology/syst/menus/runedis.scr 1>/tmp/log 2>&1
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
vz7r1x
Regular Advisor

Re: Crontab Issue

NG
Remember, the 'cron' environment is devoid of environmental variables declared in your '.profile' since it is not a login that reads your profile. Your default environment consists only of HOME, SHELL, LOGNAME and PATH and the PATH only contains '/usr/bin:/usr/sbin:.'.

A few things you can try are:
1- Try stopping/starting cron if you have not done so-
"/sbin/init.d/cron stop/start"

2- check cron log if it tells you anything
/var/adm/cron/log

3- can you attach you script for forum to test in our environment and see if we get the same result U get?
N Gopal
Frequent Advisor

Re: Crontab Issue

Thanks to all for your suggestions.

we have tried adding .profile in our start up script and also added one more library path to one of the library variables we are exporting. That solved the problem.

Thanks once again for all your suggestions.