error from Popen only when run from cron

daniel.chmielewski at gmail.com daniel.chmielewski at gmail.com
Tue Apr 17 19:11:52 EDT 2018


W dniu sobota, 27 stycznia 2018 16:59:50 UTC+1 użytkownik Larry.... at gmail.com napisał:
> 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?

Larry, I have exactly the same problem. I'd like to run a script and from normal user it works, and from cron doesn't.

In sumarry I was googled to find information how to set two or more env. variables and pass them to subprocess.open. I also try to read $HOME/.profile where usually these env. var. are setting.  Have anyone see any example how to do it? Please let me know. Regards, Daniel


More information about the Python-list mailing list