分页: 1 / 1
需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-01-25 12:25
由 速腾1994
具体的思路是每天自动运行一次
代码: 全选
rm hosts
wget https://smarthosts.googlecode.com/svn/trunk/hosts
wait
下载完成后
cp hosts /etc/hosts
exit
Re: 需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-01-25 12:41
由 速腾1994
代码: 全选
cd /etc
rm hosts
wget https://smarthosts.googlecode.com/svn/trunk/hosts
exit
Re: 需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-01-25 12:46
由 枫叶饭团
.............
Re: 需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-01-25 13:11
由 eexpress
rm?你敢随便rm啊。
你的hosts里面,前面关键的几句,网上的可通常没添加。你丢了那几句127的,你的网络/系统服务直接完蛋。
Re: 需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-01-25 13:25
由 libreoffice3writer
写好脚本后, 把这个脚本放在/etc/cron.daily/里面, 然后为脚本增加可执行的权限;
也可以用crontab命令向cron中加入它.
要注意hosts文件中的第一行的127.00.1 HOSTNAME 需要变成你系统的hostname.
Re: 需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-01-25 16:42
由 YeLee
wget -q
https://smarthosts.googlecode.com/svn/trunk/hosts -O - |diff -u /etc/hosts - |sudo patch -p0

Re: 需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-01-25 16:48
由 daf3707
eexpress 写了:rm?你敢随便rm啊。
你的hosts里面,前面关键的几句,网上的可通常没添加。你丢了那几句127的,你的网络/系统服务直接完蛋。
这个加了的
#UPDATE:13-01-21 22:11
127.0.0.1 localhost
#SmartHosts START
#Google Services START
203.208.46.200 0.docs.google.com
203.208.46.200 0.drive.google.com
需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-02-09 9:52
由 k9288k
学习一下
Re: 需要一个自动更新hosts的脚本,不知道该怎么写
发表于 : 2013-03-04 8:20
由 auv1107
cp /etc/hosts /etc/hosts.bak
备份最原始的hosts文件
cat hosts /etc/hosts.bak >/etc/hosts
脚本在/etc/networking/if-up 放个链接 这样每次链接网络都会自动更新
Sent from my M9 using Tapatalk 2