Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- running shell_exec commands as root
- Lawrence Krubner
July 11, 2008, 8:06 am
rate this thread
I've a PHP script that is run as a cron job. It contains this line:
$stringListingAllProcesses = shell_exec("lsof | grep vsftpd");
The lsof command returns almost nothing unless you are the root user.
Can anyone think of a way I can use su or sudo or something else to get
this script to run as root?
(And yes, I'm aware that it is dangerous to allow a PHP script to run as
root, but it is in an otherwise secure environment, far removed from the
Re: running shell_exec commands as root
That is what I tried first. I logged in as root and did "crontab -e".
But the script doesn't seem to run as root. The lsof in the script
seems to run as... I don't know who. It returns no data, which would
make sense for a non-root user.