Warning: Undefined array key "cperpage" in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 255

Warning: Undefined variable $output in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 325

Warning: Undefined variable $fixed_tags in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 326

Warning: Undefined variable $isshowdots in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 327

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 330

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 333

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 336

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345

Warning: Undefined variable $more_text_link in /www/wwwroot/www.now163.com/wp-content/themes/twentytwentyfive/functions.php on line 345
Shell – 第 2 页 – 理想社会

分类: Shell

  • 查看本服务器硬件信息(CPU、内存、硬盘等)

    以戴尔服务器为例:

    #!/bin/bash
    #查看服务器ip:
    ifconfig |grep -A7 “eth0” |grep “inet addr” |awk ‘{print $2}’|sed ‘s/addr://g’
    #查看服务器型号:
    dmidecode |grep -A8 “System Information” |grep “Product Name”|sed ‘s/^[ t]*//’
    #查看硬件编号:
    dmidecode |grep -A8 “System Information” |grep “Serial Number” |sed ‘s/^[ t]*//’
    #现有内容数量和容量:
    dmidecode |grep -A16 “Memory Device” |grep “Size” |sed ‘s/^[ t]*//’
    #最大支持内存容量:
    dmidecode |grep “Maximum Capacity” |sed ‘s/^[ t]*//’
    #查看CPU类型和主频:
    cat /proc/cpuinfo |grep “model name”
    #硬盘容量:
    fdisk -l |grep “Disk” |awk ‘{print $2$3$4}’

    (更多…)

  • shell脚本监控mysql服务器状态

    目的:
    1.监控mysql服务器的状态
    2.当发现mysql down机就自动重启mysql服务
    3.重启mysql不成功,发邮件给管理员警告mysql down机

    #vi /usr/local/sbin/sbin/check_mysql.sh
    (更多…)

  • awk计算某天是星期几

    unix 下的 cal 没有办法具体计算 哪天是星期几,写了个 awk 计算:

    echo "20110703" | awk '{ i=0; cald[0] = 0;
    mon = substr( $1, 5,2 )
    year = substr( $1, 1,4 )
    d = substr( $1, 7 )
    print $1
    while("cal"" "mon" "year | getline)
    {
    i++;
    if( i>2 )
    {
    for( j =1; j <=  NF;  j++ )
    {
    if( i == 3 )
    week = ( 7 - NF + j -1)
    else
    week = j == 1? 7: j-1
    cald[$j>=10?$j:"0"$j] = week
    }
    }
    }
    print cald[d]
    }'