Trying to run crontab
Question: I'm trying to run a cron job with crontab -e. I'm using a python code

    
    
    #!/usr/bin/env python
    import webbrowser
    handle = webbrowser.get()
    handle.open_new_tab('http://www.youtube.com/watch?v=Y4QGPWLY-EM')
    

running crontab -e i have:

    
    
    * * * * * python /home/sean/imBlue.py >>/tmp/out.txt 2>&1
    

And i keep getting these error messages

    
    
    Traceback (most recent call last):
      File "/home/sean/imBlue.py", line 3, in <module>
        handle = webbrowser.get()
      File "/usr/lib/python2.7/webbrowser.py", line 52, in get
        raise Error("could not locate runnable browser")
    webbrowser.Error: could not locate runnable browser
    

I'm not sure what I need to include or what I am doing wrong. When I run the
script in bash: python scriptName.py I don't have any issues. Also i have
changed the settings of the file to chmod a+x.


Answer: A `crontab` entry will run even if you are not logged, and does not keep the
environment.

You need at least to set and export the `DISPLAY` variable in your crontab
(assuming that indeed you are logged to an X11 session at time of crontab)

Perhaps changing the `crontab` entry to

    
    
      * * * * * env DISPLAY=:0.0 python /home/sean/imBlue.py >>/tmp/out.txt 2>&1
    

could help. Of course if you are not logged on at that time it won't work

My feeling is that your whole script is a huge mistake, or a bad trick: you
don't want to play every minute a video of more than 5 minutes!

