I have a very simple requirement which i tried looking for solution but couldn't get any standard defined solution . what i want to know is for my question below what is the correct
solution.
Question: i am required to run a cronjob ( which is a python script ) using crontab.
using crontab -e i added this line to my cron file:
* * * * * /usr/bin/python /srv/x/y/src/run.py > /tmp/listener.log 2>&1
the script starts but it is using environment variables inside. i get an error in log file that the env vars are not defined?
where should i define my env vras? i even tried to define in .bashrc
but still the same error. cronjob cannot find it.
what am i missing?
export VAR=value
to have the variables actually passed to the environments of the commands you run. Theset
builtin assigns values to the positional parameters (among other things). Tryset x=blah; printf "x: $x\n1: $1\n"
– ilkkachu Apr 18 '17 at 21:46