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 the PATHs are not used from bashrc. Is there a file I can enter the PATHs into for cron like bashrc or a way to call the PATHs from bashrc?
Sorry I don't think I worded this correctly, I can get the correct script to run (meaning the PATH to the script in crontab is not the problem here), it's just when that script is running I run a build and this uses the PATHs set in .bashrc
. When I run the script when I'm logged in, the .bashrc
PATHs are pulled in. Since cron doesn't run in a shell per say it does not pull in .bashrc
. Is there a way of pulling this in without having to write a bash script wrapper?
source /etc/profile
, it should eat.bashrc
and a whole lot of other potentially missing things for you. Explicit profile sourcing gets pretty useful if you want some scripts to run "standalone", it also protects from weird environments and so...sh
scripts called by crontab work. You can confirm it updates the path by adding a job like* * * * * echo $PATH > ~/crontab_path.txt
and checking the file after a minute.