|
Posted by theGerm on 03/29/07 17:55
On Mar 29, 11:16 am, "petersprc" <peters...@gmail.com> wrote:
> On Mar 29, 11:59 am, "theGerm" <jrmo...@gmail.com> wrote:
>
> > Is it possible for me to restart a service with PHP? I need to run
> > this from a webpage
>
> > /sbin/service squid reload
>
> You could do somethine like:
>
> $cmd = 'sudo /sbin/service squid reload 2>&1';
> exec($cmd, $output, $exitCode);
> if ($exitCode != 0) {
> trigger_error("Command \"$cmd\" failed with exit code $exitCode: " .
> join("\n", $output), E_USER_ERROR);
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -
With this
<?PHP
$cmd = 'sudo /etc/init.d/squid reload 2>&1';
exec($cmd, $output, $exitCode);
if ($exitCode != 0) {
trigger_error("Command \"$cmd\" failed with exit code $exitCode:
" .
join("\n", $output), E_USER_ERROR);
?>
The page stays blank but the server does not seem to reload.
[Back to original message]
|