Not able to execute a url from python script running via Cron

I have a script web.py which I am trying to run on the aws EC2 Instance using cron. It basically has these line of codes:

import webbrowser
webbrowser.open(')

If I run this script through putty using "python web.py" it does hit the browser. But same is not working if I run it via cron. My cron code is :

*/10 * * * * /usr/bin/python /home/web.py

The way I know its not working is there are few process which get executed once the url is hit. I can see those changes when I run the script through putty but not when I run it through cron.

I tried below modifications also but its not working.

*/10 * * * * export DISPLAY=:0 && /usr/bin/python /home/web.py
*/10 * * * * DISPLAY=:0 /usr/bin/python /home/web.py

Also on echo $DISPLAY I get a null result. Any help would be appreciated.

2

1 Answer

Adding a semicolon worked for me:

*/10 * * * * export DISPLAY=:0; /usr/bin/python /home/web.py

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like