I am trying to include a call to restart the apache2 server within an .sh script using PHP that runs daily to perform a maintenace routine on my server. I am able to kill the apache server and clear any queued apache processes by placing pkill -9 apache2 within an exec call for php. I am doing it this way to ensure that any apache processes that are build up on the server get removed and do not affect the running of the server.
once the apache processes are killed, I try to restart the apache server by calling /etc/init.d/apache2 restart within a similar exec call, however I get the following error:
sh: /etc/init.d/apache2/: not found
If I run the same command from the command line is executes as expected, just not within the .sh script. Other shell commands within this script also execute without problems.
If anyone can shed some light on this issue I will be very greatful. Thanks in advance.