LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crontab (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-938433/)

nagabhushan 04-06-2012 03:16 AM

crontab
 
Why cron needs PATH variables should be set explicitly in it ??
when I scheduled a shell script through cron, the result was different comared to running the same script through console. Then I googled a lot and i found that PATH variables should be explicitly defined in cron and it worked, my script executed correctly. I dont understand why this should be done. Please explain me....

malekmustaq 04-06-2012 03:29 AM

Probably your script assigned to cron for execution called for universal paths from the root stand point?

catkin 04-06-2012 03:42 AM

We can only speculate why the designers or cron (in both its Vixie a.k.a ISC cron or Dillon a.k.a. dcron versions) decided to restrict the PATH value the way they did. It may have been for security.

Changing the default value of PATH in the crontab(s) is one way around that. A better way is for each script to set the PATH (and any other shell/process configurations: umask, limits, locale ...) it requires. That is good defensive programming practice; it makes scripts robust.


All times are GMT -5. The time now is 11:45 AM.