linux下删除指定crontab定时任务
来源:互联网 发布:飞鸽软件下载 编辑:程序博客网 时间:2024/05/21 00:53
1、新建两个脚本文件用来进行测试
test1.sh
ping 114.114.114.114
test2.sh
ping 8.8.8.8
2、通过crontab -e命令编辑crontab任务,增加内容如下:
*/1 * * * * /dd/shell/test1.sh
*/1 * * * * /dd/shell/test2.sh
添加完成后,查看下crontab内容:
[root@localhost shell]# crontab -l
*/1 * * * * /dd/shell/test1.sh
*/1 * * * * /dd/shell/test2.sh
增加了crontab任务后,在/var/spool/cron目录下会有一个当前登录账号命名的文件。比如我的登录账号是root。则会存在一个root文件。该文件的内容就是刚添加的crontab任务。
[root@localhost cron]# cat /var/spool/cron/root
*/1 * * * * /dd/shell/test1.sh
*/1 * * * * /dd/shell/test2.sh
3、删除crontab内容里的test2.sh的任务
其实该处是使用sed命令来处理/var/spool/cron/root 文件,将含test2.sh的行的内容删除掉。
sed -i '/test2.sh/d' /var/spool/cron/root
命令执行完后,再通过crontab -l命令查看。
[root@localhost shell]# crontab -l
*/1 * * * * /dd/shell/test1.sh
可以看到test2.sh的任务被删除掉了。通过观察,test2.sh的脚步也不再被执行。说明确实删除成功。
4、删除crontab内容空白行
在执行完上面的sed -i的命令后,crontab -l会发现多出一行空白,如果你觉得看的别扭,你可再通过如下sed命令把空白行删除掉。
sed -i '/^$/d' /var/spool/cron/root
0 0
- linux下删除指定crontab定时任务
- linux 下 crontab 定时访问指定url
- linux 系统下定时执行任务 crontab
- Linux下学习crontab定时任务笔记
- crontab linux下oracle备份 定时任务
- 关于linux下定时任务 crontab
- linux下crontab定时任务不能执行
- Linux下 crontab命令--定时任务
- linux下的定时任务,Crontab用法
- Linux系统下的定时任务Crontab
- Linux下定时任务配置-crontab
- linux下定时任务(crontab)
- linux下定时任务crontab的使用
- linux 下设置定时任务 crontab命令
- linux下的crontab定时任务
- Linux下的定时任务crontab设置
- Linux下的定时任务crontab设置
- Linux下crontab定时任务服务
- poj3264 树状数组找最大值问题
- Ubuntu 14.04 LTS下安装 LNMP环境
- 干货一:通过自定义PopupWindow实现QQ菜单选项功能
- CSDN-markdown编辑器使用说明
- NSFontAttributeString 富文本对象的属性
- linux下删除指定crontab定时任务
- poj3468 树状数组的区间快速更新和查询
- 软件设计模式——模版方法模式(Template Pattern)
- 如何阅读一本书(13)
- Spark作业优化总结
- Android greenDAO使用方法解析
- 数据库基本语句
- Delphi开发经验谈
- iOS开发总结之block回调以AFN为基础封装的网络请求操作类