Tag:Shell script
-
Use Shell script in CentOS to automatically backup website files and databases every day and upload them to FTP
1. Install Email Sending Program copy codecode show as below: yum install sendmail mutt Second, install the FTP client program This script needs to use the FTP client program to upload files to the FTP space, so the FTP client must be installed, otherwise the error that the ftp command cannot be found will occur.For […]
-
A simple shell script to monitor the number of Squid running processes and automatically restart
copy codecode show as below: #!/bin/sh while sleep 30 do SquidNum=`ps -ef|grep squid|grep -v grep|wc -l` #HttpNum=`netstat -an|grep 0.0.0.0:80|grep -v grep|wc -l` #80Status if [ $SquidNum != 3 ] ; then /etc/rc3.duid start adddate=`date +%Y-%m-%d`” “`date +%H:%M:%S` echo “$adddate squid started!” >> /home/resquid.log fi #Restart the squid service after more than 5000 http requests HttpNum=`netstat […]
-
Shell script combined with PHP script to collect the pv and alexa ranking of the website
This is a script written for a friend. It is for cdn. We often encounter attacks, but we cannot block the domain name as soon as we encounter an attack. We can make judgments selectively. This is the php value alexa value: copy codecode show as below: <?php $yuming = $argv[1];//Get the alaxe ranking function […]
-
Shell script implements memcache cache hit rate monitoring
The company has several servers running multiple memcached processes. In addition to monitoring whether they are telneted normally and whether the instance exists, they must also monitor their cache hit rate. Alert on their cache hit ratio. There is a perl written on the Internet, which needs to be compiled and installed. There is a […]
-
Number guessing game implemented by shell script
Generated passwords and user input can accept duplicate numbers.Therefore, it may be much more difficult to guess the number compared to the general rules. Rules for this version: A–number pair, position is also rightB–After excluding the result of A, the numbers are right, but the position is wrong After starting, a 4-digit repeatable number such […]
-
Shell script to analyze the region where the ip is located in the apache log
The component used to query the ip address copy codecode show as below: wget http://rfyiamcool.googlecode.com/files/nali-0.1.tar.gz tar zxvf nali-0.1.tar.gz cd nali-0.1 ./configure && make && make install The steps are similar to nginx, but the method of getting the ip address in the log is different~~~ copy codecode show as below: #!/bin/bash #rfyiamcool IPSUMFILE=access_ip.log SAVEFILE=ipaddress.txt echo […]
-
Shell script implementation prevents foreign IP from accessing the server
According to the customer’s requirements, I don’t want foreign IP to access the server. I originally wanted to let the computer room route at the upper end, but those people don’t bird you~~~~In this case, you can only solve it with iptables~~~~~~~~~You can go to the IP library http://www.ipdeny.com/ipblocks/ Download, here are the ~ ~ […]
-
Shell script traverses directories and modifies file codes in batches
When porting JSP Web pages on windows to Linux environment, it was found that it was too slow to convert coding and modify the default coding type one by one. Write this script to try file traversal~ I haven’t written for a long time, but my hand is born. Copy codeThe code is as follows: […]
-
Three methods of judging variables as numbers in shell scripts
Method 1: calculate the variable by expr and add it to an integer value. If it can be executed normally, it will be an integer. Otherwise, the execution error, $? Will be a value other than 0 Copy codeThe code is as follows: expr $args + 0 &>/dev/null Method 2: print the variable, replace the […]
-
Shell script sharing for obtaining server information (Ubuntu and CentOS tests passed)
This script has been tested on Ubuntu and CentOS versions. The script is as follows: Copy codeThe code is as follows: #!/bin/bash Line=’===========’ #Linux distribution name if [[ -f /usr/bin/lsb_release ]]; then OS=$(/usr/bin/lsb_release -a |grep Description |awk -F : ‘{print $2}’ |sed ‘s/^[ \t]*//g’) else OS=$(cat /etc/issue |sed -n ‘1p’) fi echo -e “${Line}\nOS:\n${OS}\n${Line}” ###################################################################################################### […]
-
Shell script speed up and slow down the system time (used when testing the server)
Recently, the company’s server testing needs to often adjust the system time. Oneortwo are better than half. If there are a little more, there will be all kinds of entanglements. The author is going crazy with these machines. One word from the boss: all speed up by 3 minutes After a meeting, all of them […]
-
Shell script realizes status code analysis in Apache logs
1、 First, cut Apache logs by day Copy codeThe code is as follows: vi /etc/httpd/conf/httpd.conf ErrorLog “|rotatelogs /var/log/httpd/%Y%m%derror_log 86400 480” CustomLog “|rotatelogs /var/log/httpd/%Y%m%daccess_log 86400 480” combined 2、 Restart Apache service Copy codeThe code is as follows: service httpd restart ##################Apahce log server cutting is completed by day###################### 3、 Analyze the generated […]