Automatic emptying of Yandex.Disk trash without human intervention

Having taken care of backups on my modest server, I was faced with an obvious next step - where to store all this stuff?







There is no particular choice, and I have a free Yandex Disk on which, with all the bonuses, I already have 63 GB, it's a sin not to use it.







In principle, I solved the problem, but like many other users I discovered that the place is not rubber and the basket must be periodically cleaned, otherwise the place quickly ends, but there is no time and the ability to constantly climb into the web interface and clean the basket. Disorder, needs to be corrected.







Let's spend 10-15 minutes and forget about the problem for a year, let's go.







Input data on which everything works for me:







Ubuntu 18.04
Yandex.Disk     
      
      





  1. Let's go under the login from which your poison works at https://oauth.yandex.ru/ and click the Register a new application button









  2. Fill in the fields as shown in the screenshot









  3. In the Access point, select Yandex Disk REST API and check the boxes as in the screenshot









  4. We go down to the very bottom of the page and click the Create application button









  5. , (PS , )









  6. , https://oauth.yandex.ru/authorize?response_type=token&display=popup&client_id=id ID 5















  7. , !















  8. nano /root/yadisk.sh
          
          











    #!/bin/sh
    /usr/bin/curl -s -H "Authorization: OAuth _" -X "DELETE" https://cloud-api.yandex.net/v1/disk/trash/resources/?path=
          
          





    _ 8













  9. chmod 700 /root/yadisk.sh
          
          





  10. crontab -e







    0 3 * * * /root/yadisk.sh > /dev/null 2>&1
          
          





    , . 3 .









, :)

— , , .













/usr/bin/curl -s -H "Authorization: OAuth _" -X "DELETE" https://cloud-api.yandex.net/v1/disk/trash/resources/?path=
      
      





( _)

.







.








All Articles