linux - 如何删除 crontab 中的特定行?

标签 linux bash shell

下面提到的脚本有我的 crontab 运行功能。

# Chef Name: binary_log_purge 0 */4 * * * /engineyard/bin/binary_log_purge -q
# Chef Name: database_oom_score
*/30 * * * * /engineyard/bin/database_oom_adj
# Chef Name: logrotate -f /etc/logrotate.d/stats 0 * * * * logrotate -f /etc/logrotate.d/stats
# Chef Name: cpu_utilaisation
*/5 * * * * cd /tmp && sh cpu_util.sh >> cpu_utilaisation.log
# Chef Name: Test_script
*/2 * * * * cd /tmp && sh test.sh >> tests_cript.log

上述查询我想删除吹气线

# Chef Name: Test_script
*/2 * * * * cd /tmp && sh test.sh >> tests_cript.log

如何通过以下步骤删除该功能:

第1步:首先我想知道下面的行是否存在。我怎样才能知道?

*/2 * * * * cd /tmp && sh test.sh >> tests_cript.log

第 2 步:如果该线存在。我想删除该功能。我怎样才能删除该功能?

请帮帮我......

最佳答案

根据man 5 crontab crontab 文件不能直接编辑。

你能做的就是运行crontab -l ,使用 grep -v 过滤掉该行, 运行crontab -r清除 crontab,然后将 crontab 文件的修改版本通过管道传输到 crontab - .

关于linux - 如何删除 crontab 中的特定行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35408241/

相关文章:

linux - 共享集群与采用 Intel(R)Core™ i7 的笔记本电脑之间的性能检查

c++ - 编译器错误 C4244 : 'initializing' : conversion from '__int64' to 'int' , 可能丢失数据

regex - bash 脚本中使用的以下 sed 行的含义

macos - 有没有办法在 OS X 中使用 shell 更改键盘快捷键

linux - 如何记录 "screen"命令生成的 session 的输出?

linux - 从 cron 运行时,顶级命令输出为空

python - 在 (i)python session 之间保留命令历史记录

linux - UNIX `time` 命令对于基准测试是否足够准确?

json - Bash,管道解析和格式化 json(瘦身)

linux - 编写 Shell 脚本