Answer the question
In order to leave comments, you need to log in
How to run a command as user via shell_exec?
After certain manipulations with synchronization, there is a task to restart the apache server, now this is done manually.
Tell me how to correctly run the command I need through shell_exec on behalf of the user, and not from the apache user?
For example, I try in code:shell_exec('killall -9 apache2');
Answer the question
In order to leave comments, you need to log in
I recommend doing this in two steps.
The script accepts a task and writes it to the database.
Every minute, the script is launched by the crown from the root, it checks if there are tasks in the database and executes them.
After completion - deletes the task or marks it as completed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question