Discussion:
[Supervisor-users] running exec from php script within supervisor process
Rolando Bermúdez Peña
2015-02-10 22:50:50 UTC
Permalink
Hello all,

I have configured supervisor the latest version, to run a php script like
this:

...
command=php /path/to/the/script.php
...

But in that script i execute the function exec to run other processes
within the php script, in the error log that i have configured for that
program supervisor shows

sh: 1: commandname: not found

commandname is the one that i try to execute using exec within the php
script.
And of course the commandname exists and runs fine using the same user
supervisor uses.

Any ideas of how can get this to work?
Thanks in advance.

Rolando Bermudez
Matt Black
2015-02-10 22:58:32 UTC
Permalink
Hi Rolando,

That would be because PHP’s exec function is starting sh as the shell to
execute your command (hence the “sh: “ in the output), and this shell does
not have an environment setup like your current login shell.

Try running env in your login shell and see the output. Then run echo
exec('env'); via your PHP script and see how little there is :)

To fix it try using absolute paths to all programs called via exec - like
/usr/local/bin/pip as opposed to just pip.

Cheers
​
Post by Rolando Bermúdez Peña
Hello all,
I have configured supervisor the latest version, to run a php script like
...
command=php /path/to/the/script.php
...
But in that script i execute the function exec to run other processes
within the php script, in the error log that i have configured for that
program supervisor shows
sh: 1: commandname: not found
commandname is the one that i try to execute using exec within the php
script.
And of course the commandname exists and runs fine using the same user
supervisor uses.
Any ideas of how can get this to work?
Thanks in advance.
Rolando Bermudez
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Loading...