标签:
建立脚本 /var/beifei/create.sh
添加执行权限chmod +x create.sh
然后添加crontab定时任务
0 0 * * * /var/beifei/create.sh
脚本文件如下
#! /bin/bash tDir=$(date ‘+%Y%m%d%H‘); tDir="/var/beifei/$tDir"; echo $tDir; if [ ! -d $tDir ];then mkdir $tDir; fi mysqldump -uroot -ppassword dbname > "$tDir/name.sql" mkdir "$tDir/source/" cp -r /var/www/op_system/app "$tDir/source/app" cp -r /var/www/op_system/config "$tDir/source/config" cp -r /var/www/op_system/public "$tDir/source/public" cp -r /var/www/op_system/resources "$tDir/source/resources" cp -r /var/www/op_system/.env "$tDir/source/.env" find /var/beifei/* -maxdepth 0 -type d -mtime +15 -exec rm -rf {} \;
标签:
原文地址:http://www.cnblogs.com/xiaozong/p/5872508.html