|
|

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 |
|
发表评论:
|
|