How to get CRON to call in the correct PATHs

前端 未结 15 1219
时光取名叫无心
时光取名叫无心 2020-11-22 06:07

I\'m trying to get cron to call in the correct PATHs. When I run a Python script from shell the script runs fine as it uses the PATHs set in bashrc but when I use cron all t

15条回答
  •  广开言路
    2020-11-22 06:37

    @Trevino: your answer helped me solve my problem. However, for a beginner, trying to give a step by step approach.

    1. Get your current installation of java via $ echo $JAVA_HOME
    2. $ crontab -e
    3. * * * * * echo $PATH - this lets you understand whats the PATH value being used by crontab at present. Run crontab and grab $PATH value used by crontab.
    4. Now edit crontab again to set your desired java bin path: a) crontab -e; b) PATH=/bin:/usr/bin:/bin (its a sample path); c) now your scheduled job/script like */10 * * * * sh runMyJob.sh &; d) remove echo $PATH from crontab as its not needed now.

提交回复
热议问题