Rebuild ctrl + alt + del (restart by default) as a script for collecting information

Source: Internet
Author: User

A. if you press ctrl + alt + del for the first time and press ctrl + del within 60 seconds, the firewall will be disabled and the sshd service will be restarted after N information collection tasks are executed;
B. If the server cannot be connected, press ctrl + alt + del to restart the server.
The procedure is as follows:
1. First modify the current/etc/inittab file and change the default restart to/root/checksystem. sh. Copy codeThe Code is as follows: sed-I's # ca \: ctrlaltdel \: \/sbin \/shutdown \-t3 \-r \ now # ca \:\: ctrlaltdel \: \/bin \/sh \/root \/checksystem \. sh # '/etc/inittab

2. Run the "init q" command to reload the file.Copy codeThe Code is as follows: init q

3. Create the/root/checksystem. sh script file. The content is as follows. The specific meaning is not detailed. You can enrich the content on your own.Copy codeThe Code is as follows :#! /Bin/bash
# History
#2011-04-28 Caoyameng ver1.0
#
Test-e/root/systeminfo_lock & exit 0
Touch/root/systeminfo_lock
Test-e/root/systeminfo &/bin/mv/root/systeminfo/root/systeminfo_bak
Echo "#1">/root/systeminfo
Date>/root/systeminfo
Echo "#2">/root/systeminfo
Df-h>/root/systeminfo
Echo "#3">/root/systeminfo
Free-m>/root/systeminfo
Echo "#4">/root/systeminfo
Iostat>/root/systeminfo
Echo "#5">/root/systeminfo
W>/root/systeminfo
Echo "#6">/root/systeminfo
Netstat-lntp>/root/systeminfo
/Sbin/ifconfig>/root/systeminfo
Echo "#7">/root/systeminfo
Iptables-L>/root/systeminfo
Echo "#8">/root/systeminfo
Ping-c 2-W 2 127.0.0.1>/root/systeminfo
Ping-c 2-W 2 here, change to the IP address of eth0>/root/systeminfo
Ping-c 2-W 2 here change to the IP address of eth1 (if eth1 exists)>/root/systeminfo
Ping-c 2-W 2 www.linuxtone.org>/root/systeminfo
Echo "#9">/root/systeminfo
Route-n>/root/systeminfo
Echo "#10">/root/systeminfo
/Etc/init. d/iptables stop
Echo "#11">/root/systeminfo
/Etc/init. d/sshd restart
/Etc/init. d/network restart
####################
Sleep 60
Sed-I's # ca \: ctrlaltdel \: \/bin \/sh \/root \/checksystem \. sh # ca \: ctrlaltdel \: \/sbin \/shutdown \-t3 \-r \ now # '/etc/inittab
Rm-f/root/systeminfo_lock
Init q

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.