Home > OS >  Gain time, find out the corresponding files deleted after failure
Gain time, find out the corresponding files deleted after failure

Time:10-04

Now=$(date + "H % Y % m % d % % m % S")
The File=esp - $Now. SQL

SevenDays=$(date - d - 1 day + "H % Y % m % d % % m % S")
If [-f/opt/itrus esp_backold/esp - $SevenDays. SQL]
Then
Rm - rf/opt/itrus/esp_backold/esp - $SevenDays. SQL
Echo "You have the delete 1 days line bak file"
The else
Echo "1 days line bak file not exist", "
Fi


Get SevenDays value, and then according to the value under the corresponding path to delete the previous file, has been deleted (file exists), after some problems appeared in SevenDays, but I don't know what the reason, which a great god knows!

CodePudding user response:

You take time is (date) (month) (year) hours, minutes seconds, you can make sure the file name on the corresponding

CodePudding user response:

Esp - 20190721101725. This is to generate the SQL file name before test after remove the minutes when also can't

CodePudding user response:

refer to the second floor cs383450139 response:
esp - 20190721101725. This is to generate the SQL file name before test after remove the minutes when is no


You put your/opt/itrus esp_backold files in the directory

CodePudding user response:



The first file to the next period of time

CodePudding user response:

If every day is only one file, you can use a SevenDays=$(date - d - 1 day + "% Y % m % d)", only keep (date) (month) (year)
The if of judgment, and delete, use * instead of hours, minutes, seconds,
The esp - ${SevenDays} *. SQL

CodePudding user response:

I also encountered this problem
  • Related