【发布时间】:2014-09-02 03:05:42
【问题描述】:
我正在编写一个需要在 PHP 中动态添加 crons 的脚本。我使用此命令插入新作业:
ssh2_exec($connection, '(echo "* * * * * /usr/local/bin/php -q /home/username/www/index.php 1 '.$user.' >/dev/null 2>&1 ") | crontab -u username -');
$user 是一个变量。
现在,如果 $user 被删除,我想删除他们相关的 cron 作业。
有没有办法从 crontab 中删除特定的行?我知道
crontab -u username -r
将删除用户名的所有 cron,但我不想这样做。
【问题讨论】: