How to get CRON to call in the correct PATHs

前端 未结 15 1225
时光取名叫无心
时光取名叫无心 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条回答
  •  猫巷女王i
    2020-11-22 07:02

    If you don't want to have to make the same edits in various places, then roughly do this:

    * * * * * . /home/username/.bashrc && yourcommand all of your args
    

    The . space and then the path to .bashrc and the && command are the magic there to get your environment changes into the running bash shell. Too, if you really want the shell to be bash, it is a good idea to have a line in your crontab:

    SHELL=/bin/bash
    

    Hope it helps someone!

提交回复
热议问题