My situation is that I have a php file at /root/test.php.
And I set my root’s crontab like this
* * * * * /usr/local/bin/php /root/test.php
The content of test.php worked for generate the aliase database for postfix just like the following:
<?php echo shell_exec("postaliases hash:/etc/aliases"); >
I know that the test.php is successfully run by crontab.
But the shell_exec inside doesn’t seem to work(I can’t find my target aliases.db file under /etc/).
And I have tested use commend php -f test.php directly is work.
I know the situation is a little complex. But if someone can solve my problem, I will be very appreciate your for help.
Use the full path to postaliases. Most likely it is not in the path of the user executing the script
Why do use a php script to call a shell? Just use a shellscript