I have a Python script that manages a series of CasperJS tasks and processes the result. It works well from the command line, but when I run the script in cron, I get an error:
CalledProcessError: Command '['/path/to/casperjs', '/path/to/doSomething.js', 'args']' returned non-zero exit status 1
In Python, I call CasperJS:
response = subprocess.check_output(['/path/to/casperjs', '/path/to/doSomething.js', 'args'], shell=True)
I also tried shell=False
and Popen
, but I get the same result. I also tried to make the whole command a string (instead of a list), but that didn't help either.
Running '/path/to/casperjs /path/to/doSomething.js args'
returns a return code of 0 when run in the shell.
I also added PATH=/usr/bin:/bin:/sbin:/usr/local/bin
to my crontab to no avail. (As suggested in this question .)
Any ideas why I only get this error in cron? Thanks!!
EDIT: According to the answer below setting shell=False
and stderr=subprocess.STDOUT
made everything work ...
source share