centos 设置定时任务执行指定脚本
发布时间:2016-7-12 13:46:00 阅读次数:
 

  vim /etc/crontab

  [plain] view plain copy print?

  1.  1 SHELL=/bin/bash

  2.  2 PATH=/sbin:/bin:/usr/sbin:/usr/bin

  3.  3 MAILTO=root

  4.  4 HOME=/

  5.  5

  6.  6 # For details see man 4 crontabs

  7.  7

  8.  8 # Example of job definition:

  9.  9 # .---------------- minute (0 - 59)

  10. 10 # |  .------------- hour (0 - 23)

  11. 11 # |  |  .---------- day of month (1 - 31)

  12. 12 # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...

  13. 13 # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

  14. 14 # |  |  |  |  |

  15. 15 # *  *  *  *  * user-name command to be executed

  16. 16

  17. 17 01 0 * * * root /data/backup/168/backup.sh

  18. 18 01 0 * * * root /data/backup/ty/backup.sh

  vim /data/backup/168/backup.sh

  [plain] view plain copy print?

  1.1 rq=` date +%Y%m%d%H%M%S`

  2.2 mysqldump etdsprodb -uroot > /data/backup/168/etdsprodb_$rq.sql

  3.3

  4.4 rq=` date +%Y%m%d%H%M%S`

  5.5 mysqldump etdsreport -uroot > /data/backup/168/etdsreport_$rq.sql

  6.6

  7.7 rq=` date +%Y%m%d%H%M%S`

  8.8 svnadmin dump /data/svnrepos/etds|gzip  > /data/backup/168/svnetds_$rq.dump.tar.gz