"Crontab" mistakenly deleting crontab and its recovery

Source: Internet
Author: User

The Mid-Autumn Festival is coming, first of all wish yourself a happy mid-autumn.

Yesterday six o'clock in the afternoon, the heart is thinking of adding a crontab can work. Originally wanted to execute CRONTAB-E, did not think of hand shake on the input of crontab, and then entered the following look.

When you see something wrong, press Ctrl + D.

Then, the horrible thing happened and all the crontab's tasks were emptied.

Find data found below:

That's what I'm feeling right now.

However, he deleted the crontab, on his knees to find back.

Emperor do not bear the painstaking people, the way is still there. Crontab has a running log, which allows you to find the history commands that have been executed in the log. The prerequisite is to have root privileges.

The command is as follows:

CAT/var"' which cron '" >./all_temp cat  . " <command> " >./cmd_temp

The command can be obtained by reading Cmd_temp with awk.

[script- tmp]$ cat cmd_temp  'cmd'{print $}  ' | Sort | uniq (bash   /home/appadmin/script/security/auto_restart.sh)

The order was retrieved, but the execution cycle? Still rely on the cmd_temp.

[script- Genevatmp]$ Cat Cmd_temp | grep/home/appadmin/script/security/auto_restart.sh |Head Sep One Geneva: -: onscript- Genevacrond[18487]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: $: onscript- Genevacrond[18522]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: $: onscript- Genevacrond[18844]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: -: onscript- Genevacrond[18870]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: -: onscript- Genevacrond[18901]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: the: onscript- Genevacrond[19036]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: -: onscript- Genevacrond[19073]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva:Wuyi: onscript- Genevacrond[19147]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: the: onscript- Genevacrond[19286]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh) Sep One Geneva: -: onscript- Genevacrond[19312]: (appadmin) CMD (bash/home/appadmin/script/security/auto_restart.sh)

It can be seen clearly that the command is a minute at a time.

After all, it's one hours after work. Anyway, I finally filled out the pit.

"Crontab" mistakenly deleting crontab and its recovery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.