使用crontab计划任务更新公司群邮件账户
时间:2014-10-01 08:59 来源:linux.it.net.cn 作者:it
用crontab计划任务更新群邮件账户的方法,制作了一个shell脚本
通过extman后台别名功能增加了公司群邮件账户,包含公司所有真实用户。
实现了一个shell脚本,借助crontab,实现每晚自动更新一次。
代码如下:
复制代码代码示例:
#!/bin/bash
user=username
passwd=password
domain=@domain.com
group=all@domain.com
mysql -u$user -p$passwd -e "select username from extmail.mailbox where username like '%$domain' and active=1;" >userlist.txt
gotouser=`grep -v "username" userlist.txt |awk '{printf $0","}'`
mysql -u$user -p$passwd -e "update extmail.alias set goto ='$gotouser' where address='$group';"
rm -rf userlist.txt
(责任编辑:IT)
用crontab计划任务更新群邮件账户的方法,制作了一个shell脚本
通过extman后台别名功能增加了公司群邮件账户,包含公司所有真实用户。
代码如下:
复制代码代码示例:
#!/bin/bash
user=username passwd=password domain=@domain.com group=all@domain.com mysql -u$user -p$passwd -e "select username from extmail.mailbox where username like '%$domain' and active=1;" >userlist.txt gotouser=`grep -v "username" userlist.txt |awk '{printf $0","}'` mysql -u$user -p$passwd -e "update extmail.alias set goto ='$gotouser' where address='$group';" rm -rf userlist.txt |