通过bash脚本删除cron作业

时间:2021-10-18 08:01:54

I'm creating a cron job in a script like this:

我正在这样的脚本中创建一个cron作业:

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
crontab -l > crontask
grep "* * * * * $DIR/somescript" crontask || echo "* * * * * $DIR/somescript" >> crontask

I'd like to build a script that can delete this job, how should I do that?

我想建立一个可以删除这份工作的脚本,我应该怎么做?

1 个解决方案

#1


-1  

A quick google search and you got it :

快速谷歌搜索,你得到它:

crontab -l | grep -v "* * * * * $DIR/somescript"  | crontab  -

And to add a cron task :

并添加一个cron任务:

{ crontab -l ; echo "* * * * * $DIR/somescript"; } | crontab -

#1


-1  

A quick google search and you got it :

快速谷歌搜索,你得到它:

crontab -l | grep -v "* * * * * $DIR/somescript"  | crontab  -

And to add a cron task :

并添加一个cron任务:

{ crontab -l ; echo "* * * * * $DIR/somescript"; } | crontab -