I have a cron job like the following:
07 14 * * 1-5 python /home/foo/cronscript.py
The script:
if __name__ == '__main__':
f = open(开发者_如何学Go'/home/foo/cronpass.txt','w')
f.write('abc')
f.close()
Checking the syslog I suppose the command did run, but with an error:
Aug 29 14:07:01 ubuntuserver CRON[16490]: (www-data) CMD (python /home/foo/cronscript.py)
Aug 29 14:07:01 ubuntuserver CRON[16488]: (CRON) error (grandchild #16490 failed with exit status 1)
Question: what does the error means? Does it means an error occurred while trying to execute the script, or that there is an error in my script?
What could be the error?
The usual error with crontab
tasks, is that the environment in which they run don't have all the env. vars. you're accustomed to. Maybe here, PATH
is not set to all the usual directories, and cron does not find the executable python
. You should write the full path to it. as follows.
07 14 * * 1-5 /usr/bin/python /home/foo/cronscript.py
精彩评论