error from Popen only when run from cron

Dan Stromberg drsalists at gmail.com
Sat Jan 27 11:30:26 EST 2018


If you have your script set $PATH and $HOME, you can test it with:

env - ./my-script

The difference between running a script from the command line, and
running a script from cron, is often environment variables. env -
clears the environment.

On Sat, Jan 27, 2018 at 7:58 AM, Larry Martell <larry.martell at gmail.com> wrote:
> I have a script that does this:
>
> subprocess.Popen(['service', 'some_service', 'status'],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>
> When I run it from the command line it works fine. When I run it from
> cron I get:
>
>     subprocess.Popen(['service', 'some_service', 'status'],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>   File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
>     errread, errwrite)
>   File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
>     raise child_exception
> OSError: [Errno 2] No such file or directory
>
> Anyone have any clue as to what file it's complaining about? Or how I
> can debug this further?
> --
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list