#安装发信
yum -y install sendmail
#启动发信服务
service sendmail start
#发信
mail -s “[$(date +’%F %H:%M:%S’)] 标题” xxx@xxx.com < /opt/mail.txt
#启动crontab 定时执行
service crond start
#执行进入crontab vi
crontab -e
#增加 此为每5分钟执行一次脚本
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * /opt/tomcatre/tomcat.sh
#重启crontab
service crond restart
http://tool.lu/crontab/ 定时测试工具
#!/bin/sh
array=( table1 table2 )
echo “#!/bin/sh” >/opt/hb/hbdel.sh
echo “hbase shell <<EOF”>>/opt/hb/hbdel.sh
for data in ${array[@]}
do
echo delete_snapshot \’${data}”_”$(date -d “last month” +%Y%m)”05″\’>>/opt/hb/hbdel.sh
done
echo “EOF”>>/opt/hb/hbdel.sh
echo “echo [$(date +’%F %H:%M:%S’)] delete_snapshot >>/opt/hb/hbdel.log” >>/opt/hb/hbdel.sh
/opt/hb/hbdel.sh
本文链接地址: linux shell脚本、定时、重启、二级执行、发信