【发布时间】:2019-04-23 06:16:45
【问题描述】:
我创建了一个 test.php 文件并编写了一些代码
$output = [];
exec('ps aux', $output);
var_dump($output);
当我从 cli 运行它时
php test.php
我得到的结果是正确的,例如
root 60826 0,0 0,0 12568 1612- IJ 21:14 0:00,00 cron:正在运行的作业 (cron)
但如果它添加到 crontab,我写响应文件,可以看到字符串被切断。示例
root 60826 0,0 0,0 12568 1612- IJ 21:14 0:00,00 cron:运行 j
我的操作系统 FREEBSD
【问题讨论】:
-
您如何将响应写入文件?
-
添加到 crontab 如 1 * * * * command > file
-
来自箭头的好解决方案