Using a PHP script in a crontab is fairly easy, as stated in the “Using PHP from the command line” documentation… Until you start to get the following warning during the execution:
No entry for terminal type “unknown”;
using dumb terminal settings.
The script works, but this nasty warning really bothers you.
Here is a sample crontab entry:
* * * * * root sudo -u www-data php -r ‘echo “test”;’
When executed, it prints the warning on STDERR.
Yes, I know I don’t need “sudo” here, but this was my initial usage pattern as I discovered the problem, and at the first time I suspected that “sudo” got crazy. Well, it wasn’t “sudo” to blame, but PHP.
Here is the fixed crontab entry:
* * * * * root sudo -u www-data TERM=dumb php -r ‘echo “test”;’
The issue was encountered on an Ubuntu 10.04 server. I though crond usually sets $TERM to something… Anyway, problem solved.