I've been searching on the internet but haven't found the correct answer to my question. Here is my question in detail:
There is python opening a web browser.I can run it manually on terminal and it worked well.
But when I put it into crontab,the web browser can not be opened. This is my contab command:
*/1 * * * * /usr/bin/python /home/pi/test.py 2>&1 >/dev/null | tee -a /home/pi/test.log
Please notice that this is a DISPLAY problem. Python was executed successfully.
I checked the log created by crontab and it says:
Cannot connect to X server
So I tried to add env variables in my contab and changed it into:
*/1 * * * * export DISPLAY=:0.0 && /usr/bin/python /home/pi/test.py 2>&1 >/dev/null | tee -a /home/pi/test.log
Still it does not work. And I add something else into crontab like:
/usr/bin/xhost +
/usr/bin/ssh pi@localhost -X
But it just does not work!
Now I don't know what to do. Can anyone tell me what is wrong with it and how to solve it? Thank you very much!
Sincerely, Helen