0

I have a problem where scripts called by cron have very short, safe, path: /usr/bin:/bin

I know, that I can:

  1. Change scripts to use better path
  2. in user crontab add PATH=... configuration

But I'd like to be able to tell crond that on this system all crons should be called with PATH=...

I tried putting it in /etc/crontab:

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

And then, for tests, I wrote:

=# cat /etc/cron.d/test 
* * * * *  test echo "$( date ) - ${PATH}" >> /tmp/test.cron.log

But logged path is still "/usr/bin:/bin"

I did restart crond, and even rebooted, just in case, but it doesn't seem to help. What am I missing? Or is it impossible?

eijeze
  • 427
  • 1
  • 5
  • 11
  • 1
    No implementation of `cron` that I have examined has a standard configuration mechanism whereby you can define environmental variables such as `PATH` which then will be included in each crontab file automatically. – fpmurphy Nov 25 '20 at 16:06
  • OK, Thanks. Knowing that there is no solution is also a solution :) – eijeze Nov 30 '20 at 12:17

0 Answers0