Script produces different result when executed by Bash than by cron

前端 未结 3 2039
不知归路
不知归路 2021-01-18 20:36

Please consider following crontab (root):

SHELL=/bin/bash
...
...
0 */3 * * * /var/maintenance/raid.sh

And the bash script /var/maint

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 21:03

    As indicated in the comments, do use full paths on crontab scripts, because crontab does have different environment variables than the normal user (root in this case).

    In your case, instead of mdadm, /sbin/mdadm makes it.

    How to get the full path of a command? Using the command command -v:

    $ command -v rm
    /bin/rm
    

提交回复
热议问题