Koozali.org: home of the SME Server

Legacy Forums => General Discussion (Legacy) => Topic started by: Bill on August 12, 2003, 05:34:09 AM

Title: e-smith PHP question? How to restart a service?
Post by: Bill on August 12, 2003, 05:34:09 AM
Sorry for the slightly OT post but this seems to be a SME specific problem (or a serious case of can't see the forest for the trees.)

I would like to be able to restart a service (spamassassin) from within a php script. I can modify the template fragment fine and can expand the template fine but cannot get the service restart command to work.  I have tried the system() command and the exec() command and both just error out.  What is the trick here?

TIA,

Bill
Title: Re: e-smith PHP question? How to restart a service?
Post by: Nathan Fowler on August 12, 2003, 05:36:52 AM
Permissions issue, apache, running under WWW, does not have permissions to restart the service.

You could create a simple bash script that would check for the existance of a file and execute it.  This file would be writable by WWW and would contain the command to restart the service.  Using PHP, you could simply fopen() and write the command to this file.

Then, you simply cron the bash script that checks for that files existance.
Title: Re: e-smith PHP question? How to restart a service?
Post by: Bill on August 12, 2003, 05:41:01 AM
Great idea, its hard to see the problem when surrounded by trees :)
Title: Re: e-smith PHP question? How to restart a service?
Post by: Nathan Fowler on August 12, 2003, 08:51:30 AM
No problem bro ;)