On Tue, Apr 17, 2018 at 4:11 PM, <daniel.chmielew...@gmail.com> wrote: > W dniu sobota, 27 stycznia 2018 16:59:50 UTC+1 użytkownik larry....@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
Is service on your $PATH in the cronjob? What if you set the variables you need in the program, and test it with "env - myscript" in a login shell, to run myscript with an empty environment? This tends to make under cron and not under cron more similar. HTH -- https://mail.python.org/mailman/listinfo/python-list