run python script using crontab " Error: <urlopen error [Errno -2] Name or service not known>"

asked 2014-05-08 06:47:56 -0600

Zeinab gravatar image

I use fedora19 and python2.7. I try to run python script from bash script to upload file to a website using crontab. the script runs from terminal but doesn't work from crontab and the error is " Error: <urlopen -2]="" [errno="" error="" known="" name="" not="" or="" service="">" please, can anyone help me?</urlopen>

Zeinab

edit retag flag offensive close merge delete

Comments

Please provide the python traceback, or even better the python code line which performs the upload + the crontab line.

marcindulak gravatar imagemarcindulak ( 2014-05-08 07:51:02 -0600 )edit

the python code line:

!/usr/bin/env python

from ConfigParser import ConfigParser from mechanize import Browser, RobustFactory import base64 from os.path import basename import sys

crontab :

05 15 * * * /usr/bin/python mypath/upload.py datapath/files_data/data.nc >&logfile

Zeinab gravatar imageZeinab ( 2014-05-08 08:16:27 -0600 )edit

People often report such problems due to proxy problems http://bit.ly/1irx3ai . Try to trim down you script to a minimum urlopen call and debug from there http://stackoverflow.com/questions/20264953/random-errno-2-name-or-service-not-known-errors

marcindulak gravatar imagemarcindulak ( 2014-05-08 08:34:08 -0600 )edit