zoukankan      html  css  js  c++  java
  • 常用脚本总结

    1、适用于把多个人添加到同一个邮件组里

    from DB import DB                 #导入自定义的数据库模块
    con,cur = DB().connect()        #创建连接
    
    with open('/tmp/python_test/test.txt','r') as f:        #打开文件并读取每一行
        for line in f.readlines():
            bam_list = line.strip()   #去掉首尾空格
            try:
                insert = 'insert into mail.forward(name,forward_name) values ("bam_expats", "%s")' % bam_list
                cur.execute(insert)
                con.commit()
            except Exception, e:
                pass  
    #print type(e),e #显示错误信息

    #执行多次会提示数据已被添加。所以得try 。

    2、同步文件

    #!/bin/sh
    
    local_file=/data01
    pid_file=/var/run/rsyncd.pid
    
    pid=$(cat $pid_file )
    if [ $pid ]
    then
            ps $pid > /dev/null
            if [[ $? == 0 ]]
            then
                    echo exist
                    exit 1
            fi
    fi
    
    echo $$ > $pid_file
    rsync -avz root@10.12.1.2::data  $local_file > /var/run/$(date +%F).log --exclude={IOD,ITD,WUXI,share,EXO}   --password-file=/etc/rsyncd.secret
    

      

  • 相关阅读:
    loadOnStartup = 1
    TP复习8
    TP复习7
    TP复习6
    TP复习5
    TP复习4
    TP复习3
    TP复习2
    TP复习
    document.createElement("A");
  • 原文地址:https://www.cnblogs.com/luck123/p/8567753.html
Copyright © 2011-2022 走看看