您当前所在位置:首页技术分享备份ubuntu网站任务(Crontab)

备份ubuntu网站任务(Crontab)

更新:2022-05-21 09:03:37编辑:Story归类:技术分享人气:163
摘要

备份ubuntu网站任务(Crontab)

使用Crontab和寫一個sript

建立一個script

vi /data/backup/weekly.sh

內容如下

#!/bin/bash
#
# This program is created by hdj 2004/02/03
#
# What is this program?
# This program will backup the following messages:
# 1. mysql data (/var/lib/mysql);
# 2. www( /var/www/ )
#
# HOW TO RUN THIS PROGRAM?
# Just put the file into /etc/crontab job,
# or put this file's link file to /etc/cron.weekly!
# or modify the /etc/crontab
back=/data/backup/www_backup
tar -zcf $back/mysql.tar.gz /var/lib/mysql
tar -zcf $back/www.tar.gz /var/www

==============================================================

再修改/etc/crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file.
# This file also has a username field, that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
25 6 * * * root test -e /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6 * * 7 root test -e /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6 1 * * root test -e /usr/sbin/anacron || run-parts --report /etc/cron.monthly
#

45 20 * * 1 root /data/backup/weekly.sh <==加入這行

成长的对话版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

黑客攻防之 SYN攻击基本原理与防范技术 Sendmail配置终极指南(简略)