Shell Basic Applications

Source: Internet
Author: User

Experiment (I.)

Experimental purpose: Detect system once per minute "The root partition has less than 10G of free space to send warning messages to all terminals. "

Experimental requirements: Write a script and automate the script.

Experimental Analysis:

1. First extract the information from your system/partition and extract the free space of the root partition based on your/partition information.

2. Send a warning message to all terminals.

3. Writing a scheduled task .

Experimental steps:

1. Write a script, create a folder under/below the shell, and write a check_disk.sh script under the shell folder.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/49/wKiom1Y0ef-RrYYxAACKDQpXuVU127.jpg "title=" Qq20151031162108.png "alt=" Wkiom1y0ef-rryyxaackdqpxuvu127.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/46/wKioL1Y0fLTQBpk1AAEdXBOYxcc026.jpg "title=" Qq20151031163145.png "alt=" Wkiol1y0fltqbpk1aaedxboyxcc026.jpg "/>

2. Execute permissions for scripts

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/49/wKiom1Y0eyvjqHL4AADpn_2NMss973.jpg "title=" Qq20151031162607.png "alt=" Wkiom1y0eyvjqhl4aadpn_2nmss973.jpg "/>

3. Writing a scheduled task

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/49/wKiom1Y0fELAXYaTAADo4-9ZSfY962.jpg "title=" Qq20151031163039.png "alt=" Wkiom1y0felaxyataado4-9zsfy962.jpg "/>

4. Experimental testing

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/49/wKiom1Y0fWaAgw5LAAEVppQMOcA325.jpg "title=" Qq20151031163529.png "alt=" Wkiom1y0fwaagw5laaevppqmoca325.jpg "/>

Experiment (II)

Experimental purpose: 23:30 per day for a full backup of the BBSDB library in the MySQL database.

Experimental requirements: Automatic backup via script to TIME

Experimental Analysis:

1. Use mysqldump to make a backup of the database.

2. Add variables to the backup command to make the script more complete and flexible.

3. Write the Scheduled tasks.

Experimental steps:

1. Create a Database Bbsdb library

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/49/wKiom1Y0g22R2fQ4AAFqqtUTixY529.jpg "title=" Qq20151031164945.png "alt=" Wkiom1y0g22r2fq4aafqqtutixy529.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/47/wKioL1Y0g7Cgrz7VAAFy5r_JOjY987.jpg "title=" Qq20151031165002.png "alt=" Wkiol1y0g7cgrz7vaafy5r_jojy987.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/49/wKiom1Y0g4PyaBDFAAMWUAQPnrQ588.jpg "title=" Qq20151031170118.png "alt=" Wkiom1y0g4pyabdfaamwuaqpnrq588.jpg "/>

2. Scripting backup Bbsdb A full backup in the library

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/47/wKioL1Y0ilPCddEDAABItvStJs8222.jpg "title=" Qq20151031172952.png "alt=" Wkiol1y0ilpcddedaabitvstjs8222.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/4B/wKiom1Y0mgLwziSIAAGPAP9qKVo178.jpg "title=" Qq20151031183736.png "alt=" Wkiom1y0mglwzisiaagpap9qkvo178.jpg "/>

3. Add execute permissions to the script

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/47/wKioL1Y0ipHAJHupAADZgzGC01g121.jpg "title=" Qq20151031173054.png "alt=" Wkiol1y0iphajhupaadzgzgc01g121.jpg "/>

4. Writing a scheduled task

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/47/wKioL1Y0iyXzeZrMAADpSE6_53U375.jpg "title=" Qq20151031173319.png "alt=" Wkiol1y0iyxzezrmaadpse6_53u375.jpg "/>

5. Test to see if the backup file has been generated and view the message.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/4A/wKiom1Y0i-uDbq2HAAD3N-Fbi1I455.jpg "title=" Qq20151031173735.png "alt=" Wkiom1y0i-udbq2haad3n-fbi1i455.jpg "/>

6. Delete the tables in the database with the backed up files for recovery.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/49/wKioL1Y0m2-S_-N8AAEmQjGtHiM972.jpg "title=" Qq20151031184111.png "alt=" Wkiol1y0m2-s_-n8aaemqjgthim972.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/4B/wKiom1Y0m0ODfGhyAAEu4t_g3Io341.jpg "title=" Qq20151031184249.png "alt=" Wkiom1y0m0odfghyaaeu4t_g3io341.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/49/wKioL1Y0m4Tiv1mVAAFssrVxtt4670.jpg "title=" Qq20151031184223.png "alt=" Wkiol1y0m4tiv1mvaafssrvxtt4670.jpg "/>


Summary: script files can be automatically executed in a system-scheduled task by scripting, which is a good way for operations personnel.


This article is from the "Down to earth" blog, make sure to keep this source http://343614597.blog.51cto.com/7056394/1708393

Shell Basic Applications

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.