星期六, 10月 08, 2005

利用cron job 及lftp 同步資料實作note

建立一個shell script ftpsync.sh 內容如下
#vi ftpsync.sh
#!/bin/bash
#使用lftp同步,根據/root/filesync.lftp 指令內容同步
lftp -f /root/filesync.lftp

建立要同步的檔案 filesync.lftp 內容如下
#vi filesync.lftp
# -u --> user testftp --> 使用者名稱 test 密碼 192.168.0.225 -->遠端主機 ip
open -u testftp,test 192.168.0.225
#切換本地端目錄到/ftpsync 必須先建立此目錄
lcd /ftpsync
#開始mirror 只針對較新的檔案
mirror -n

#chmod u+x /root/ftpsync.sh
排入cron job
#crontab -e
0 2 * * * /root/ftpsync.sh

完成