crontab命令的用法
usage: crontab [-u user] file crontab [-u user] [ -e | -l | -r ] (default operation is replace, per 1003.2) -e (edit user's crontab) -l (list user's crontab) -r (delete user's crontab) -i (prompt before deleting user's crontab)
所以,
$output = shell_exec('crontab -l');file_put_contents('/tmp/crontab.txt', $output.'* * * * * NEW_CRON'.PHP_EOL);echo exec('crontab /tmp/crontab.txt');如果用户具有足够的文件写入权限,则以上内容可用于 创建和编辑/附加 。
删除作业:
echo exec('crontab -r');另外,请注意,apache以特定用户身份运行,并且通常不是root用户,这意味着cron作业只能为apache用户更改,除非为apache用户赋予了
crontab-u特权。



