I use popen to execute commands in a Python script, and I call it through cron.
Cron calls this script, but the behavior is not the same if I call it manually.
A source:
from subprocess import Popen, PIPE pp = Popen('/usr/bin/which iptables', shell=True, stdout=PIPE) data = '' for ln in pp.stdout: data = data+ln if data == '': print 'ko' else: print 'ok : '+data
Hand:
In cron (in / tmp / err_cron):
* * * * * /usr/bin/python /home/user/test.py >> /tmp/err_cron ko ko ko
Why doesn't cron run this script normally?
python cron console
Kevin campion
source share