Friday, August 04, 2006

Shell script and Cron的練習

Objective: 每一分鐘使用tar,將eric的家目錄備份到/tmp下,格式為year-month-day-hour-minute.tgz

# su - eric
$ cd /home/eric/bin
$ vi backup.sh
#!/bin/bash
DATE=`date +%Y-%m-%d-%H-%M`
tar zcvf /tmp/"$DATE".tgz /home/eric
$ chmod 755 backup.sh
$ crontab -e
* * * * * /home/eric/bin/backup.sh

No comments: