I've got a cron script, written in PHP, that does this call:
lsof | greg vsftpd
and saves the output in a text file.
When I ssh to the server and login as root and call this script myself, everything works fine. That is, if I do this:
I get the full list of files opened by vsftpd, saved to a text file, just like I would expect.
When the cron calls this script, it creates the file, like it should, but the file is empty.
Why is that? Is lsof limited to root users or something?
This is the PHP script that I'm calling as a cron, every 5 minutes:
$stringListingAllProcesses = shell_exec("lsof | grep vsftpd");
$filename = "/usr/local/bin/bluesugar_content_ingester/ftp_processes_" . time();
This should cause files to be created in the folder "bluesugar_content_ingester". And the files are created. When I'm logged in as root, they are full of the output of lsof command. But when the script is called as a cron, the file is created, yet it is blank. It's as if there is no output.
Why would that be?