CentOS mysql web定时备份删除脚本与权限


一、backup.sh

脚本

#/bin/bash
mysqldump --user=root --password='' --databases abc | gzip > /Back/www.dejaview.cn-`date +%Y%m%d%H%M`.sql.gz
tar czf abc.com-`date +%Y%m%d%H%M`.tar.gz /usr/local/nginx/html/abc.com
find /Back -name "*.gz" -mtime +7 -exec /bin/rm {} \;

文件属性:组root[0],拥有者root[0],777

二、web目录

文件属性:组root[0],拥有者nobody[99]

三、nginx,php

两个均是nobody下运行

四、问题

目前mysql可以定时导出来,不过web目录无法压缩,也无法删除7天以前的压缩包

五、错误日志

Feb  1 00:00:01 www CROND[6149]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 00:01:01 www CROND[6159]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 00:01:01 www run-parts(/etc/cron.hourly)[6159]: starting 0anacron
Feb  1 00:01:01 www anacron[6168]: Anacron started on 2013-02-01
Feb  1 00:01:01 www anacron[6168]: Jobs will be executed sequentially
Feb  1 00:01:01 www anacron[6168]: Normal exit (0 jobs run)
Feb  1 00:01:01 www run-parts(/etc/cron.hourly)[6170]: finished 0anacron
Feb  1 00:10:01 www CROND[6233]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 00:20:01 www CROND[6324]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 00:30:01 www CROND[6388]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 00:40:01 www CROND[6460]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 00:50:01 www CROND[6542]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 01:00:01 www CROND[6612]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 01:01:01 www CROND[6621]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 01:01:01 www run-parts(/etc/cron.hourly)[6621]: starting 0anacron
Feb  1 01:01:01 www anacron[6630]: Anacron started on 2013-02-01
Feb  1 01:01:01 www anacron[6630]: Jobs will be executed sequentially
Feb  1 01:01:01 www anacron[6630]: Normal exit (0 jobs run)
Feb  1 01:01:01 www run-parts(/etc/cron.hourly)[6632]: finished 0anacron
Feb  1 01:10:01 www CROND[6699]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 01:20:01 www CROND[6767]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 01:30:01 www CROND[6847]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 01:40:01 www CROND[6917]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 01:50:01 www CROND[6987]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 02:00:01 www CROND[7057]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 02:01:01 www CROND[7065]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 02:01:01 www run-parts(/etc/cron.hourly)[7065]: starting 0anacron
Feb  1 02:01:01 www anacron[7074]: Anacron started on 2013-02-01
Feb  1 02:01:01 www anacron[7074]: Jobs will be executed sequentially
Feb  1 02:01:01 www anacron[7074]: Normal exit (0 jobs run)
Feb  1 02:01:01 www run-parts(/etc/cron.hourly)[7076]: finished 0anacron
Feb  1 02:10:01 www CROND[7132]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 02:20:01 www CROND[7197]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 02:30:01 www CROND[7266]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 02:40:01 www CROND[7336]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 02:50:01 www CROND[7401]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 03:00:01 www CROND[7473]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 03:01:01 www CROND[7481]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 03:01:01 www run-parts(/etc/cron.hourly)[7481]: starting 0anacron
Feb  1 03:01:01 www anacron[7490]: Anacron started on 2013-02-01
Feb  1 03:01:01 www anacron[7490]: Will run job `cron.daily' in 39 min.
Feb  1 03:01:01 www anacron[7490]: Jobs will be executed sequentially
Feb  1 03:01:01 www run-parts(/etc/cron.hourly)[7492]: finished 0anacron
Feb  1 03:10:01 www CROND[7555]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 03:20:01 www CROND[7621]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 03:30:01 www CROND[7687]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 03:40:01 www anacron[7490]: Job `cron.daily' started
Feb  1 03:40:01 www run-parts(/etc/cron.daily)[7792]: starting logrotate
Feb  1 03:40:01 www run-parts(/etc/cron.daily)[7800]: finished logrotate
Feb  1 03:40:01 www run-parts(/etc/cron.daily)[7792]: starting makewhatis.cron
Feb  1 03:40:01 www CROND[7829]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 03:40:01 www run-parts(/etc/cron.daily)[7921]: finished makewhatis.cron
Feb  1 03:40:01 www run-parts(/etc/cron.daily)[7792]: starting tmpwatch
Feb  1 03:40:01 www run-parts(/etc/cron.daily)[7959]: finished tmpwatch
Feb  1 03:40:01 www anacron[7490]: Job `cron.daily' terminated
Feb  1 03:40:01 www anacron[7490]: Normal exit (1 job run)
Feb  1 03:50:01 www CROND[8023]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 04:00:01 www CROND[8089]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 04:01:01 www CROND[8105]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 04:01:01 www run-parts(/etc/cron.hourly)[8105]: starting 0anacron
Feb  1 04:01:01 www run-parts(/etc/cron.hourly)[8114]: finished 0anacron
Feb  1 04:10:01 www CROND[8238]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 04:20:01 www CROND[8317]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 04:30:01 www CROND[8401]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 04:40:01 www CROND[8475]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 04:50:02 www CROND[8544]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 05:00:01 www CROND[8609]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 05:01:01 www CROND[8617]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 05:01:01 www run-parts(/etc/cron.hourly)[8617]: starting 0anacron
Feb  1 05:01:01 www run-parts(/etc/cron.hourly)[8626]: finished 0anacron
Feb  1 05:10:01 www CROND[8685]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 05:20:01 www CROND[8748]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 05:30:01 www CROND[8811]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 05:40:01 www CROND[8873]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 05:50:01 www CROND[8942]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 06:00:01 www CROND[9009]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 06:01:01 www CROND[9017]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 06:01:01 www run-parts(/etc/cron.hourly)[9017]: starting 0anacron
Feb  1 06:01:01 www run-parts(/etc/cron.hourly)[9026]: finished 0anacron
Feb  1 06:10:01 www CROND[9089]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 06:20:01 www CROND[9159]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 06:30:01 www CROND[9223]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 06:40:01 www CROND[9288]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 06:50:01 www CROND[9353]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 07:00:01 www CROND[9419]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 07:01:01 www CROND[9427]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 07:01:01 www run-parts(/etc/cron.hourly)[9427]: starting 0anacron
Feb  1 07:01:01 www run-parts(/etc/cron.hourly)[9436]: finished 0anacron
Feb  1 07:10:01 www CROND[9494]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 07:20:01 www CROND[9557]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 07:30:01 www CROND[9622]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 07:40:01 www CROND[9684]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 07:50:01 www CROND[9752]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 08:00:01 www CROND[9817]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 08:01:01 www CROND[9825]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 08:01:01 www run-parts(/etc/cron.hourly)[9825]: starting 0anacron
Feb  1 08:01:01 www run-parts(/etc/cron.hourly)[9834]: finished 0anacron
Feb  1 08:10:01 www CROND[9891]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 08:20:01 www CROND[9958]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 08:30:01 www CROND[10025]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 08:40:01 www CROND[10090]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 08:50:01 www CROND[10188]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 09:00:01 www CROND[10287]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 09:01:01 www CROND[10295]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 09:01:01 www run-parts(/etc/cron.hourly)[10295]: starting 0anacron
Feb  1 09:01:01 www run-parts(/etc/cron.hourly)[10304]: finished 0anacron
Feb  1 09:10:01 www CROND[10395]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 09:20:01 www CROND[10459]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 09:30:01 www CROND[10521]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 09:40:01 www CROND[10585]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 09:50:01 www CROND[10652]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 10:00:01 www CROND[10716]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 10:01:01 www CROND[10724]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 10:01:01 www run-parts(/etc/cron.hourly)[10724]: starting 0anacron
Feb  1 10:01:01 www run-parts(/etc/cron.hourly)[10733]: finished 0anacron
Feb  1 10:10:01 www CROND[10799]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 10:20:01 www CROND[10864]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 10:30:01 www CROND[10926]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 10:40:01 www CROND[10992]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 10:46:01 www CROND[11035]: (root) CMD (/Back/backup.sh)
Feb  1 10:50:01 www CROND[11087]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 11:00:01 www CROND[11184]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 11:01:01 www CROND[11192]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 11:01:01 www run-parts(/etc/cron.hourly)[11192]: starting 0anacron
Feb  1 11:01:01 www run-parts(/etc/cron.hourly)[11201]: finished 0anacron
Feb  1 11:10:01 www CROND[11280]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 11:20:01 www CROND[11675]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 11:30:01 www CROND[11740]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 11:40:01 www CROND[11809]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 11:50:01 www CROND[11882]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 12:00:01 www CROND[12239]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 12:01:01 www CROND[12247]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 12:01:01 www run-parts(/etc/cron.hourly)[12247]: starting 0anacron
Feb  1 12:01:01 www run-parts(/etc/cron.hourly)[12256]: finished 0anacron
Feb  1 12:10:01 www CROND[12352]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 12:20:01 www CROND[12440]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 12:30:01 www CROND[12548]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 12:40:01 www CROND[12638]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 12:50:01 www CROND[12804]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 13:00:01 www CROND[12953]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 13:01:01 www CROND[12962]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 13:01:01 www run-parts(/etc/cron.hourly)[12962]: starting 0anacron
Feb  1 13:01:01 www run-parts(/etc/cron.hourly)[12971]: finished 0anacron
Feb  1 13:10:01 www CROND[13099]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 13:20:01 www CROND[13236]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 13:30:01 www CROND[13370]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 13:40:01 www CROND[13471]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 13:50:01 www CROND[13550]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 14:00:01 www CROND[13630]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 14:01:01 www CROND[13657]: (root) CMD (run-parts /etc/cron.hourly)
Feb  1 14:01:01 www run-parts(/etc/cron.hourly)[13657]: starting 0anacron
Feb  1 14:01:01 www run-parts(/etc/cron.hourly)[13666]: finished 0anacron
Feb  1 14:10:01 www CROND[13780]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 14:20:01 www CROND[13956]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Feb  1 14:30:01 www CROND[14128]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)

shell mysql centos

耻骨前弯的消失 11 years, 4 months ago

贴报错才是王道吧,凭空想象很难。

Madao纸箱 answered 11 years, 4 months ago

Your Answer