Shell Programming Enterprise Combat (Test)

Source: Internet
Author: User
Tags apache log mysql automatic backup

1. Write a script, implement batch add 20 users, username user1-20, password is user followed by 5 random characters

2. Shell Utility case: Batch generation of random character files

3. Please use at least the 两种 method to achieve! Change all of the Oldboy in the above file name to Oldgirl (implemented in a for loop), and the HTML is changed to uppercase.

  1. [[email protected] ~]# ll /oldboy/
  2. total 0
  3. -rw---r-- 1 root root 0 jul 20 20:45 Aebccciiaj_oldboy. HTML
  4. -rw---r-- 1 root root 0 jul 20 20:45 Afffebcchb_oldboy. HTML
  5. -rw---r-- 1 root root 0 jul 20 20:45 Dbccddabbj_oldboy. HTML
  6. -rw---r-- 1 root root 0 jul 20 20:45 Ehbdaedach_oldboy. HTML
  7. -rw---r-- 1 root root 0 jul 20 20:45 Fbaacihehi_oldboy. HTML
  8. -rw---r-- 1 root root 0 jul 20 20:45 Fffabecgbc_oldboy. HTML
  9. -rw---r-- 1 root root 0 jul 20 20:45 Ffghcffegb_oldboy. HTML
  10. -rw---r-- 1 root root 0 jul 20 20:45 Hffbhfgdff_oldboy. HTML
  11. -rw---r-- 1 root root 0 jul 20 20:45 Jadafhbaaf_oldboy. HTML
  12. -rw-r--r-- 1 root root 0 Jul 20 20:45 jgfebjbebd_oldboy.HTML

4. Write a script that implements the judgment in the 10.0.0.0/24 network , the IP of the current online user is what

5. Resolving Dos attack production cases

6. Please use at least two ways to achieve! Write a script to solve the DOS attack production case. Note: Depending on the number of web logs or network connections, monitor the number of concurrent connections for an IP or PV to 100 in a short time

, that is, call the firewall command to block out the corresponding IP, monitoring frequency every 3 minutes. The firewall command is: iptables-a input-s 10.0.1.10-j DROP.

7. Shell create cleanup log script Apache log for example

8. Monitor CPU and Memory usage

9.Shell Programming Script: Print 99 multiplication table

Use the bash for loop to print words in the following sentence that are not more than 6 in number of letters.

I am Oldboy teacher Welcome to Oldboy Trainingclass

11. How to make a backup of the MySQL database with sub-databases, please use the script to implement.

Shell MySQL Automatic backup script

Shell script: Disk monitoring

14. Monitoring MySQL master-slave synchronization is abnormal and alarm enterprise case simulation

Monitor MySQL master-slave synchronization is abnormal, if the exception, send SMS or mail to the administrator. Note: If there is no master-slave synchronization environment, you can use the following text in the file to read to simulate:
Phase 1: Develop a daemon script to detect every 30 seconds.
Phase 2: If the following error number (1158,1159,1008,1007,1062) is present in the synchronization, the error is skipped.
Phase 3: Use array technology to implement the above script (get master-slave judgment and error number section)

15.

Print menu (fortress machine)
[Email protected]]# sh menu.sh

1.[install Lamp]

2.[install LNMP]

3.[exit]

pls input the num you want:

Requirements:

1, when the user input 1 o'clock, output "startinstalling lamp." Then execute/server/scripts/lamp.sh, script content output "Lampis installed" after exiting the script;

2, when the user input 2 o'clock, output "startinstalling lnmp." Then execute/server/scripts/lnmp.sh output "Lnmpis installed" after exiting the script;

3, when input 3 o'clock, exit the current menu and script;

4. When you enter any other characters, give the prompt "input error" and exit the script.

5, to the execution of the script to determine the relevant conditions, such as: whether the script exists, whether it can be executed, etc.

16. Batch Check multiple website address is normal

17. The following string is known to be the result of the random number variable md5sum|cut-c 1-8 intercept, please crack these strings corresponding to the md5sum before the random number?

18. Depending on the number of web logs or network connections, monitoring when an IP concurrent connection number or a short time PV reached 100 is called Firewall command to block the corresponding IP, monitoring frequency every 3 minutes

The firewall command is: iptables-a input-s 10.0.1.10-j DROP

the contents of the document are as follows:

123abc456
456def123
567abc789
789def567
Output Required:
456abc123
123def456
789abc567
567def789

There is a list of the following figures:

1th Time: 1
2nd time: 2
3rd time: 3
4th time: 5
5th time: 8
6th time: 13
7th time: 21
8th time: 34
9th time: 55
10th time: 89
11th Time: 144
Write 100 times what the number is.

21. Pass in at least three numeric parameters to the script file and calculate the maximum, minimum, and average values. You need to determine if the incoming number is sufficient, or output a warning message. The average value retains two decimal places.

If executed./file 3 4 6 5, the output is as follows:
Max number Is:6
Min number Is:3
Average is:4.50

22. Write an awk script to calculate the average score for each person, the average score per test, and the average score for each team. If a result is negative, the person misses the test, and then calculates the average score by excluding the person from the calculation. The result of the output is the following table, in the list of names, the name is 10 widths and left-aligned (prompting printf to use the%-10s format), while the average is 7 characters wide and two right-aligned decimals on the right.

23. Analyze the website log to find the IP (excluding static elements such as images, JS and CSS) that have been opened over 60 times in a minute, and use iptables to prohibit access. Join Crontab to make the script execute once per minute.

24. Calculate the 1+2+3+. +100 results. You can use a variety of methods to answer.

25. Analyze the Image Service log, ranking the log (the sum of each picture's number of times * picture size), that is, calculate the total access size for each URL

Description: The production environment application: This function can be used for IDC website traffic bandwidth is very high, and then by analyzing the server log which elements occupy too much traffic,
In order to optimize or cut the picture, compression JS and other measures.
Test data
59.33.26.105–-[08/dec/2010:15:43:56 +0800] "get/static/images/photos/2.jpg http/1.1″200 11299

26. Print 1-100 odd? Print 1-100 even numbers? Print 1-100 's and? Print 1-100 odd and? Print an even number of 1-100 and? Print a prime number of 1-100?

27. Write scripts to achieve the following functions;

Start a backup every 5 o'clock in the morning.
To back up is/var/mylog all files and directories can be compressed for backup
Backup can be saved to a single device 192, 168, 1, 2 FTP account AAA password BBB
to display the daily backup file with the date tag of the day

28. Create a function that can accept two parameters:

1) The first parameter is a URL, you can download the file, the second parameter is a directory, that is, the location of the download after the save;
2) If the user-given directory does not exist, the user is prompted to create it, or if it is created, the function returns a 51 error value to the calling script;
3) If the given directory exists, then download the file; Download command after the execution of the test file download success or not; If successful, return 0 to the calling script, otherwise, return 52 to the calling script;

29. Write a script to determine if a specified script is a syntax error, and if there is an error, then remind the user to type Q or Q to ignore the error and exit any other key to open the specified script via vim.

30. The following string is known to be the result of the random number variable md5sum|cut-c 1-8 intercept, please crack these strings corresponding to the md5sum before the random number?

31. Batch check multiple website address is normal

32. "LVS standby Node" simulation keepalved vrrp function, monitoring node, if the primary node is inaccessible, the standby node starts and configures LVS the resources that implement the master node to provide services (reminder: note ARP cache)

32. The development shell script implements the comparison of 2 integer sizes in the same way as script arguments and read-in. Alerts users to compare results in a screen-out manner. Note: It's all about developing 2 a script. When a script is passed and read read in, it is necessary to determine whether the variable is 数字 , and how many parameters are passed.

33. Monitoring memcache The service is normal, impersonate the user ( web client) detection. Use nc command plus set/get to simulate detection, and monitor response time and hit rate.

34. Monitor web all files under the Site Directory ( /var/html/www ) for malicious tampering (the contents of the file has been changed), if there is a change in the name of the file (e-mail), the scheduled task is executed every 3 minutes ( 10 minutes of time to complete).

35. Write the system startup script for rsync in the Network Service standalone process mode

36. Student Practice Lottery Topics:
Good news, the old boy training students to go out of Business Project Practice Opportunities (6th time) came (mid-month), however, the quota is limited, the number of members limited to 3 (squad Leader).
Therefore, students need to be selected, so a lottery program is required:
Requirements:
1, the implementation of the script, want to go to the students to enter the full spelling of the English name, produce a random number of 01-99 between the number, the larger the number will go to participate in project practice, the previous number has been caught, the next time can not appear the same number.
2, the first input name, the screen output information, and the name and number recorded in the file, the program can not exit continue to wait for other students input.

37. Manual development ipvsadm lvs of managed scripts Ip_vs

38. Simulated Keepalived Health Check function management LVS node,

When the node hangs (detects 2 times, interval 2 seconds) from the server pool, OK (detection 2 times, interval 2 seconds) add in
Tip: Use ipvsadm the command implementation to add and reduce LVS nodes.

39. Use the shell to process the following:
1, according to the frequency of word occurrence descending sort!
2, in descending order by the frequency of letters!

the squid project provides a number of resources toassist users design,implement and support squid installations. Please browsethe documentation and support sections for more infomation

40. Simulation keepalved vrrp function, monitoring node, if the primary node is inaccessible, the standby node starts and configures LVS the resources that implement the master node to provide services (reminder: note ARP cache)

Answer the next article

Shell Programming Enterprise Combat (Test)

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.