PHPUnit + crontab: 只有 header 输出结果到文件

PHPUnit + crontab: only header when output result to file

我想 运行 每小时在生产服务器上运行 PHPUnit 并将结果写入文件。这是 crontab 行:

0 * * * * cd /path/to/project && /usr/local/bin/phpunit --exclude-group acceptance > phpunit.result

当我 运行 该命令手动 phpunit.result 包含预期结果时,但是当使用 crontab 时 phpunit.result 中只有 PHPUnit header:

PHPUnit 4.6.4 by Sebastian Bergmann and contributors.

Configuration read from /path/to/project/phpunit.xml

如何使用 crontab 将 PHPUnit 结果正确输出到文件?

在Linux系统中这样使用推荐...

  1. sudo crontab -e =>(创建 cron 选项卡)

    -> 学习命令 = */2 * * * * wget(我每 2 分钟创建一次 crontab..)

    -> 为 crontab 创建命令 = */2 * * * * wget -q http://localhost/trigger_yoururl

    -> ^o 运行 那..

    -> ^x 退出那个..

  2. sudo crontab -l =>(cron 选项卡的列表视图)

  3. sudo crontab -r =>(删除 cron 选项卡)

您可以只使用 in with 一个使用完整路径的命令。类似于:

php /usr/local/bin/phpunit -c /path/to/project/phpunit.xml > /tmp/phpunit.log 2>&1

它也会将标准错误重定向到文件。然后你会看到当你 运行 这些测试时实际发生了什么。