Shell script automatically updates hosts to achieve wall-free access to Google_linux shell

Source: Internet
Author: User

The last time we sent a Python update Google hosts script, today saw someone sent a shell to get Google hosts script, I took to a slightly more simple processing, the following gives you the shell version of the update of Google hosts script.

Script content:

Copy Code code as follows:

Cat google_update.sh
#!/bin/bash
Data= ' Date +%y%m%d%h%m '
Curl Http://www.360kb.com/kb/2_122.html 2>/dev/null | Sed-n '/#google-hosts-2015/,/#google-hosts-2015-end/{s///g s/<.*>//g; p} ' >/tmp/hosts
Cp/etc/hosts/etc/hosts_$data.bak
Mv/tmp/hosts/etc/hosts
Cat>>/etc/hosts<<eof
127.0.0.1 Testbak localhost.localdomain localhost
:: 1 localhost6.localdomain6 Localhost6
Eof

and throw it in the crontab, update it every 3 days.
Copy Code code as follows:

0 0 */3 * */bin/sh/root/soft_shell/google_update.sh

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.