编写shell脚本
#!/bin/bash # # This is a ShellScript For Auto DB Backup and Delete old Backup # backupdir=/webserver/mysqlbackup time=` date +%Y%m%d%H ` /webserver/software/mysql/bin/mysqldump -u user -ppassword ybjc | gzip > $backupdir/name$time.sql.gz #delete find $backupdir -name "name_*.sql.gz" -type f -mtime +5 -exec rm {} \; > /dev/null 2>&1
再给shell执行权限
执行crontab -e
15 11 * * * cd /home/loganalysis/ && ./dealexcel.sh >> /home/loganalysis/error.log 2>&1
重启crontab
参考资料:http://blog.csdn.net/jkunzhang/article/details/7440215
http://blog.csdn.net/a120681076/article/details/51219277
原文:http://www.cnblogs.com/norm/p/7697674.html