2019独角兽企业重金招聘Python工程师标准>>>
1、定时任务
crontab -l
crontab -e /sbin/service crond start //启动服务/sbin/service crond stop //关闭服务
/sbin/service crond restart //重启服务
/sbin/service crond reload //重新载入配置
/sbin/service crond status //查看服务状态 */1 * * * * /opt/shell/load-check.sh
00 03 * * * /opt/shell/download_log.sh
* */1 * * * /opt/shell/diskfree.shps -ax | grep cron
2、发送邮件
#!/bin/bash
percent=`df -k | grep -v Filesystem| awk '{print int($5)}'`
for each_one in $percent
doif [ $each_one -ge 90 ];thenecho $each_oneemail_date=$(date "+%Y-%m-%d %H:%M:%S")echo "email_date : "$email_date >> /opt/disk.logecho "server : 120.132.38.102" >> /opt/disk.logdf -h >> /opt/disk.logfrom_name="shaohua"from="kaka02@17guagua.com"r1="mobilewebsvr@17guagua.com"to="<$r1>"#email_title="120.132.38.102 Disk Critical"email_content="/opt/disk.log"email_subject="120.132.38.102 Disk Critical"echo -e "To: ${to}\nFrom: \"${from_name}\" <${from}>\nSubject: ${email_subject}\n\n`cat ${email_content}`" | /usr/sbin/sendmail -trm -rf /opt/disk.logbreakfi
done