问轩博客

展开菜单

continue,break,exit小例子

continue,break,exit小例子
[root@shnne ~]# vim test.sh #!/bin/sh for ((i=0; i<=5; i++)) do    if [ $i -eq 3 ]     then        #contin...

shell批量修改文件名方法

shell批量修改文件名方法
1. 创建 [root@shnne ~]# cat mk.sh  #!/bin/sh for((i=1; i<=10; i++)) do   j=`cat /dev/urandom|head -1|md5sum|cut -c 1-5`   touch shnne/${j}_shnne_$i.html don...

for小练习

for小练习
通过for循环打印5 4 3 2 1[root@shnne ~]# cat for1.sh  #!/bin/sh for i in 5 4 3 2 1 do   echo $i done   [root@shnne ~]# cat for2.sh  #!/bin/sh f...

while计算小练习

while计算小练习
[root@shnne ~]# cat sum_* #!/bin/sh sum=0 i=1 while [ $i -le 100 ] do   let sum=sum+i   let i=i+1 done echo $sum #!/bin/sh sum=0 i=1 while ((i&...

shell编写rsync启动脚本

shell编写rsync启动脚本
[root@shnne ~]# cat rsync_start.sh  #!/bin/bash # chkconfig: 2345 58 80 # description: start and stop service for rsync . /etc/init.d/functions RSYNCBIN=&q...

case小练习

case小练习
echo -e "\033[30m 黑色字 \033[0m"   echo -e "\033[31m 红色字 \033[0m"   echo -e "\033[32m 绿色字 \033[0m"   echo -e ...

nginx的Shell启动脚本

nginx的Shell启动脚本
[root@shnne ~]# cat nginxd.sh #!/bin/bash # chkconfig: 2345 58 80 # description: start and stop service for nginx #定义的变量最好是大写. nginx_bin="/application/nginx/sbin/nginx" pid="/application/nginx1.6.2/logs/nginx.pid"...

通过Shell来监测MySQL状态

通过Shell来监测MySQL状态
#!/bin/sh port=`netstat -antup|grep mysqld|wc -l` process=`ps -ef|grep mysqld|grep -v grep|wc -l` if [ $port -ne 1 ] && [ $process -ne 2&nb...

IF语句小练习

IF语句小练习
判断内存小于100,邮件报警[root@shnne ~]# sh baojing.sh  the mem is 570,it's ok. [root@shnne ~]# vim baojing.sh  #!/bin/sh memvalue=`free -m|awk 'NR==3 {print $...

比较两个整数的大小

比较两个整数的大小
#!/bin/sh #defined the number read -p "please input two number:" a b [ -z "$a" ] || [ -z "$b" ] && { &n...

判断文件的后缀名

判断文件的后缀名
#!/bin/sh if expr "$1" : ".*\.pub" &>/dev/null  then    echo "you are using $1"  else    echo "you ...

​利用let计数监控web服务状态

​利用let计数监控web服务状态
利用let计数监控web服务状态 #监控服务状态 ServerMonitor () { #服务状态监控 timeout=10 fails=0 success=0 while true  do      /usr/bin/wget --timeout=$timeout --tries=1 http://192.168.1.1.101/&nbs...

memcache实现多网站session会话保持配置

memcache实现多网站session会话保持配置
前提:配置好LNMP和LAMP,添加好memcache的扩展1.服务端安装memcached服务端软件注意:memcached用libevent来作事件驱动,所以要先安装libevent。这两个只要./configure    make &&make install即可2.配置客户端支持memcachetar xf memcache-2.2.5.tgzcd memcache-2.2.5/application/php/b...

安装JDK

安装JDK
1.下载jdk-6u35-linux-x64-rpm.binrpm -qa|grep gcj 如果有,用rpm -e下载可以加--nodeps参数强制卸载2.rz上传jdk-6u35-linux-x64-rpm.binchmod +x jdk-6u35-linux-x64-rpm.bin./jdk-6u35-linux-x64-rpm.binrpm -ivh *.rpm3.环境变量配置有三种方法(分别是:修改/etc/profile文件,修改用户目录下的.bashr...

redis-2.6.8的配置

redis-2.6.8的配置
1.下载安装redis-2.6.8.tar.gztar xf redis-2.6.8.tar.gzcd redis-2.6.8make PREFIX=/application/redis-2.6.8 installln -s /application/redis-2.6.8/ /application/rediscp redis.conf /etc/redis.conf2.编辑配置文件vim /etc/redis.conf将daemonize no  ==>改...