在工作中,有时候需要对定时执行的任务进行注释掉;然后等某些操作完后,还需要还原到以前的状态。开始的时候,我手动进行执行,因此每次执行前,需要对当前的crontab进行备份,等还原的时候再按照原来的一个一个比对,进行还原。如果定时执行的任务少的话,还可以,如果多,肯定会出现错误的。终于我在网上找了相关的解决方案。
我们知道一般情况下,编写crontab需要使用vi编辑器进行编辑。通过vi编辑器,可以很容易的在每一行的前面加上注释符号'#',也很容易的使用vi编辑器,将每一行的已经注释的'#'去掉。例如我的crontab内容如下:
- 0 7 * * * /ngbss/mddms/funds/bin/funds.sh >/ngbss/mddms/funds/log/funds`date +\%Y\%m\%d`.log 2>&1
- 30 22 * * * /ngbss/mddms/log/rm7daysagolog.sh >/dev/null 2>&1
- 0 23 * * * /ngbss/mddms/bak_stacen_param/bak_stacen_param_day.sh >/dev/null 2>&1
- #0 5 * * * /ngbss/mddms/bak_pro/getParam.sh >/dev/null 2>&1
- #40 05 * * * /usr/bin/sh /ngbss/mddms/interface/tradechk/ALL_TRADECHK.sh > /ngbss/mddms/interface/tradechk/all_tradechk.log 2>&1
- #30 20 * * * /usr/bin/sh /ngbss/mddms/interface/tradechk/B_TRADECHK.sh > /ngbss/mddms/interface/tradechk/B_tradechk.log 2>&1
- #20 07 * * * /usr/bin/sh /ngbss/mddms/interface/tradechk/EB_RESULT/chk_bss_all.sh >/ngbss/mddms/interface/tradechk/EB_RESULT/eb.log 2>&1
- #30 21 * * * /usr/bin/sh /ngbss/mddms/interface/tradechk/EB_RESULT/chk_bss_all_MM.sh >/ngbss/mddms/interface/tradechk/EB_RESULT/eb_mm.log 2>&1
- 00 08 * * * /usr/bin/sh /ngbss/mddms/interface/tradechk/all_trade_check_to_bj.sh >/ngbss/mddms/interface/tradechk/bj.log 2>&1
- 0,10,20,30,40,50 * * * * /usr/bin/sh /ngbss/mddms/ocs/OcsYKCLogSync.sh > /ngbss/mddms/ocs/OcsYKCLogSync.log 2>&1
- 30 05 * * * /usr/bin/sh /ngbss/mddms/ocs/ToOcsPPSPaylog.sh > /ngbss/mddms/ocs/ToOcsPPSPaylog.log 2>&1
- 30 * * * * /usr/bin/sh /ngbss/mddms/ocs/UpdOcsERROrder.sh > /ngbss/mddms/ocs/UpdOcsERROrder.log 2>&1
- 50 * * * * /usr/bin/sh /ngbss/mddms/ocs/UpdOcsERROrder2.sh > /ngbss/mddms/ocs/UpdOcsERROrder2.log 2>&1
- 40 * * * * /usr/bin/sh /ngbss/mddms/ocs/UpdOcsVPNOrder.sh > /ngbss/mddms/ocs/UpdOcsVPNOrder.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/spoa/p_exec_spoa_t.sh > /ngbss/mddms/crontab_for_jk_shell/spoa/p_exec_spoa_t.log 2>&1
- 50 23 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/info114/p_exec_info114_t.sh > /ngbss/mddms/crontab_for_jk_shell/info114/p_exec_info114_t.log 2>&1
- 00 * * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/10060call/p_exec_10060_t.sh > /ngbss/mddms/crontab_for_jk_shell/10060call/p_exec_10060_t.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/hlr/p_exec_hlr_t.sh > /ngbss/mddms/crontab_for_jk_shell/hlr/p_exec_hlr_t.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/DSL112/daily/p_exec_DSL112_t.sh > /ngbss/mddms/crontab_for_jk_shell/DSL112/daily/p_exec_DSL112_t.log 2>&1
- 00 00 13 * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/DSL112/per_month/p_exec_DSL112_t.sh > /ngbss/mddms/crontab_for_jk_shell/DSL112/per_month/p_exec_DSL112_t.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/info112/bin/start.sh > /ngbss/mddms/crontab_for_jk_shell/info112/p_exec_info112_t.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/servconn/p_exec_servconn_t.sh > /ngbss/mddms/crontab_for_jk_shell/servconn/p_exec_servconn_t.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/broandFTP/bin/start.sh >> /ngbss/mddms/crontab_for_jk_shell/broandFTP/log/ftp.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/userstat/bin/start.sh >> /ngbss/mddms/crontab_for_jk_shell/userstat/log/ftp.log 2>&1
- 00 00 17 * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/userstat_m/bin/start.sh >> /ngbss/mddms/crontab_for_jk_shell/userstat_m/log/ftp.log 2>&1
- 00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/broandTest/exec_broandtest.sh >> /ngbss/mddms/crontab_for_jk_shell/broandTest/p_exec_broandtest_t.log
- 0,10,20,30,40,50 * * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/114ZZ/p_exec_114ZZ_t.sh > /ngbss/mddms/crontab_for_jk_shell/114ZZ/p_exec_114ZZ_t.log 2>&1
- #00 00 * * * /usr/bin/sh /ngbss/mddms/crontab_for_jk_shell/info112eparchy/bin/start.sh >> /ngbss/mddms/crontab_for_jk_shell/info112eparchy/log/ftp.log 2>&1
先使用crontab -e进行对crontab的编辑操作
$ crontab -e
然后使用vi的如下编辑命令
:%s/^/#/
就可以将定时执行的任务前面都加上一个'#',进行注释掉。
同样等,某些操作完成后,也是,先进行对crontab的编辑
$ crontab -e
使用如下编辑命令
:%s/^#//
就可以讲上次所有注释的定时任务,全部撤销。
阅读(46407) | 评论(0) | 转发(0) |