Linux下FTP站点同步一句话脚本。应用wget

很简单,如下:

wget -b -m -nH  ftp://user:passwd@192.168.0.1:21
简单解释:
-b:应用程序后,自动放入后台,输出日志到当前目录下wget-log文件
-m:mirror,就是镜像的意思
-nH:不产生站点的目录名,我讨厌产生那样的目录。

实现功能:单向同步,B站点为A的完全镜像。既然是同步,就不会重复下载。配合cron使用吧。
简单说一下:在同步的过程中,会在本地端,也就是B端各个层级内产生2个隐藏文件,如果只有目录的话,只产生.listing。如果有文件的话,就会产生2个文件:

.listing   用来检视目录
.tempcrc.jasfv 检视文件,并且产生CRC32的校验码,用于比对。

顺便插一句,发现man帮助真是太长了,不利于快速使用。–help倒是很好用。呵呵。
网上很多朋友,都有在找这个东西。其实只需要wget –help就会找到答案。BS自己一下,我也google了半天。
对了,产生的那个文件自己看一下。挺有意思的。我就不贴了。
追加:
想用crontab调用还是需要做些修改的。比如考虑,执行脚本的路径,和本地存放的路径,日志输出位置,所以就丰富一下命令吧。

wget -b -m -nH  -P ~/localdir -o ~/logs/output.log ftp://user:passwd@192.168.0.1:21
追加2个参数
-P:指定下载后的本地存放目录位置
-o:指定输出日志的路径

作者:kook@52zhe.cn
地址:http://www.52zhe.cn/read.php/72.htm
版权:GNU,转载时请注明“转载人”欠本人一顿饭,来日见面之时兑现!谢谢合作!

鄙人欠作者kook@52zhe.cn一顿饭(不包括酒菜以及美女伴餐)来日见面之时兑现!

Written by gegewan on 十月 5th, 2008 with no comments.
Read more articles on FreeBSD/Linux.

Related articles

No comments

There are still no comments on this article.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .