вторник, 19 сентября 2017 г.

Linux: find and delete files periodically

Create script, that finds all files, older than 30 minutes:

#!/bin/bash

TARGET_FOLDER="/var/somedir/Archive"
cd $TARGET_FOLDER
find . -type f -mtime +30 -exec rm -rf {} \;


Add to cron to run script every day at 04:00

0 4 * * * /bin/bash /scripts/SCRIPT LOCATION


Комментариев нет:

Отправить комментарий

Bash: MySql backup (file per db), restore+ users and privileges

Backup Mysql DB (file per db) #!/bin/bash USER="root" databases=`mysql -u $USER -e "SHOW DATABASES;" | tr -d "|...