crontab误删除

 

命令如下:

cat /var/log/cron* | grep -i "`which cron`" > ./all_temp
 
cat  ./all_temp | grep -v "<command>" > ./cmd_temp

 

用awk读取cmd_temp,即可得到命令。

[script-02 tmp]$ cat cmd_temp  | grep username | awk -F 'CMD' '{print $2}' | sort | uniq

 (bash   /home/appadmin/script/security/auto_restart.sh)

命令是找回了,可是执行周期呢?还是靠cmd_temp。

复制代码
[script-02 tmp]$ cat cmd_temp  | grep /home/appadmin/script/security/auto_restart.sh | head                   
Sep 11 03:44:01 script-02 CROND[18487]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:45:01 script-02 CROND[18522]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:46:01 script-02 CROND[18844]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:47:01 script-02 CROND[18870]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:48:01 script-02 CROND[18901]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:49:01 script-02 CROND[19036]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:50:01 script-02 CROND[19073]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:51:01 script-02 CROND[19147]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:52:01 script-02 CROND[19286]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
Sep 11 03:53:01 script-02 CROND[19312]: (appadmin) CMD (bash   /home/appadmin/script/security/auto_restart.sh)
复制代码

可以很明显的看出,命令是一分钟一次。

全部恢复完成后已经是下班后一个小时了。不管怎么样,总算把自己坑填好了。

 

posted @ 2018-04-23 14:46  若时光搁浅  阅读(151)  评论(0编辑  收藏  举报