LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-06-2012, 04:16 AM   #1
nagabhushan
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Rep: Reputation: 0
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....
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-06-2012, 04:29 AM   #2
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,613

Rep: Reputation: 433Reputation: 433Reputation: 433Reputation: 433Reputation: 433
Probably your script assigned to cron for execution called for universal paths from the root stand point?
 
Old 04-06-2012, 04:42 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About crontab cola Slackware 2 12-29-2009 07:00 AM
linux crontab vs unix crontab ytd Linux - General 2 08-09-2009 06:07 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 08:15 PM
man crontab(5) vs crontab(1) Canis Polaris Linux - Newbie 2 06-04-2008 05:03 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 01:35 PM


All times are GMT -5. The time now is 10:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration