We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
New design
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.11.9. Automatic directory cleaning

To automatically clean up the directory, you need tocreate cron task and specify the command to delete files.

Important points:

  • Attention! Do not under any circumstances indicate the path without ~/ at the beginning or in the form /*, since absolutely all files of all sites in one hosting account will be subject to deletion.
  • To disable recursiveness in the utility rm do not specify the key -r, leave only -f.
  • To disable recursiveness when using the utility find specify the key immediately after specifying the path -maxdepth 1.
  • For removing all files and subdirectories in a specific directory use the command:
    /bin/rm -rf ~/example.com/www/tmp/* 

    Instead example.com/www/tmp/ specify the full path to the directory whose contents you want to delete.

  • For removing all files with a specific extension in the directory and all its subdirectories use the command:
     /bin/rm -rf ~/example.com/www/tmp/*.tmp

    Instead .tmp specify the desired file extension to be removed.

  • For removing all files older than a certain number of days in a specific directory use the command:
    /bin/find ~/example.com/www/tmp/ -type f -mtime +30 -exec rm -rf {} \;

    Instead 30 specify the number of days the file should be kept.

  • For removing all files except one, use the command:
     /bin/find ~/example.com/www/tmp/ -type f ! -name 'index.php' -delete 

    To delete all files except files with a specific extension, instead of index.php indicate *.php... In this case, all files in the directory will be deleted except for files with the extension .php.