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