0

I made a very serious mistake. I was editing the crontab file of my remote server, I was as the root user and it turns out that I wrote crontab -r instead of crontab -e and without previous notice it was simply deleted.

I was looking for information and it turns out that files deleted with the crontab -r command are not stored somewhere like the recycle bin or something similar. I am very worried because there are scheduled backups and all the scripts that my hosting placed. I already communicate with them and I must wait for a response from a specialized person in a period of 24 to 48 hours, but I am very concerned. Will it be possible to recover that file?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

2 Answers2

2

You will not be able to recover the file unless you have a backup to restore it from.

For the future, I would recommend a sequence of operations like this

vi ~/.crontab              # Edit a local file
crontab ~/.crontab         # Set this file as your crontab file

If you get into the habit of only ever editing the copy and not the installed version you will always have a get-out in the event that you accidentally corrupt the copy:

crontab -l > ~/.crontab    # Create the local file as a copy of your crontab
Chris Davies
  • 116,213
  • 16
  • 160
  • 287
0

In order to recover a file, please use extundelete tool from link http://extundelete.sourceforge.net/

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • You might want to point out that it's really important the extundelete tool is not installed onto the partition that held the deleted file. – Chris Davies May 20 '19 at 10:08