这 就 是 我
最 新 公 告
站 点 日 历
最 新 日 志
最 新 回 复
最 新 留 言
博 客 搜 索
友 情 链 接
 
 
 
Shell 定时备份文件脚本
beiyue 发表于 2010/2/26 15:45:00
定时将一个目录(home/test)下的文件压缩后,备份到另一个目录(e.g:/home)

#!/bin/bash
#File:/home/backup.sh

#Others vars
BIN_DIR="/home/test/"
BCK_DIR="/home"
DATE=$(date +%Y%m%d%H%M%S)

#TODO
tar -cf /$BCK_DIR/$DATE.tar /$BIN_DIR/*
----------------------------------------------------

#定时设置:
crontab -e
40 23 * * * /home/backup.sh

# Scheduling explain
e.g:
* * * * * /home/backup.sh
As you can see there are 5 stars. The stars represent different date parts in the following order:

1. minute (from 0 to 59)
2. hour (from 0 to 23)
3. day of month (from 1 to 31)
4. month (from 1 to 12)
5. day of week (from 0 to 6) (0=Sunday)

refer to the blog:
http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/

http://adminschoice.com/crontab-quick-reference

阅读全文 | 回复(0) | 引用通告 | 编辑 | 收藏该日志
 


发表评论:

    昵称:
    密码:
    主页:
    标题: