We need /usr/local/bin in all cron's path!

we already tried to add PATH to /etc/crontab:

#/etc/crontab
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

but the test:

# crontab -e
* * * * * echo $PATH > /tmp/current_cron

still produces the old path.

link|improve this question
1  
General hint: Writing "it didn't work" will not usually get you a useful reply. Always describe how exactly it didn't work, that is, exactly what did you do, and what exactly was the result. – sleske Jul 19 '10 at 10:14
feedback

3 Answers

You can configure your PATH in crontab configuration file as shown in the first code except there. First specify the env variables, then specify jobs.

link|improve this answer
does not work on ubuntu, even after restarting cron – grosser Jul 19 '10 at 7:01
1  
@grosser: Well, it should. Please post your complete crontab (edit your answer), along with the output it produces and why you believe it does not work. Then we'll see... – sleske Jul 19 '10 at 10:06
Also note that the format of the VARIABLE=value lines is somewhat more restricted than in a shell script: Each assignment must be on a line of its own, and you may not use variables on the right-hand-side (e.g. PATH=$PATH:/bla will not work). – sleske Jul 19 '10 at 10:12
i updated the question, setting the PATH in an individual crontab did work, just the global change did not work – grosser Jul 21 '10 at 6:10
Try specifying PATH variables in each crontab where you need it. Probably it's done due to security issues. BTW, in ubuntu (I've checked) PATH is defined in /etc/crontab and /etc/cron.d/anacron in ubuntu. So it seems that it is not being inherited from /etc/crontab. Just try defining it in root's crontab (sudo crontab -e) – igorp1024 Jul 21 '10 at 14:53
feedback

Setting the PATH variable should work in Ubuntu, how do you say it is not working ?

Refer #14: Linux Crontab: 15 Awesome Cron Job Examples

link|improve this answer
i updated the question, setting the PATH in an individual crontab did work, just the global change did not work – grosser Jul 21 '10 at 6:22
feedback

If you're able to be root, can you try editing /etc/init.d/cron and changing the PATH there? I haven't tested this, but would be interesting to check.

link|improve this answer
did not seem to work, i just added PATH=xxx into /etc/init.d/cron but the * * * * * echo $PATH output was the same – grosser Aug 5 '10 at 7:21
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.