ITeye博客

Shell 修改定时器

listen-raining · 2016-10-13 17:08 · Linux shell 脚本攻略 · 编程语言 · Markdown

#!/bin/bash

#修改mondev用户的定时器(/var/spool/cron/mondev)

usage(){ echo "command is not right.." echo "sh mondev_crontab.sh ipListFile" exit }

if [ "$1" == "" ] || [ ! -r $1 ] then usage fi

root_user="root" root_pass="!13YXdgh" errlog="log/crontaberror.log"

for ip in cat $1 |awk '{print $1}' do #先清空mondev用户的定时器 errm1=sshpass -p $root_pass ssh -t -o StrictHostKeyChecking=no $root_user@$ip "echo >/var/spool/cron/mondev" if [ "$?" == "0" ] && [ "$errm1" == "" ] then #添加定时器 errm2=sshpass -p $root_pass ssh -t -o StrictHostKeyChecking=no $root_user@$ip "echo '0 */24 * * * /data/mondev/mondo/client/bin/magent restart' > /var/spool/cron/mondev"

		if [ "$?" == "0" ] && [ "$errm2" == "" ]
			then
				echo "update crontab success"
		else
			echo "update crontab fail................."
			echo "$ip \n update crontab fail.................\n" >> $errlog
		fi
		
else
	echo "clearn /var/spool/cron/mondev has error....."
	echo "$ip \n clearn /var/spool/cron/mondev has error..... \n " >> $errlog
fi

sleep 1

done

@dianxinguangchang.43F.zhongshanerlu.yuexiuqu.guangzhoushi.guangdongsheng

2016年10月13日 星期四 17时10分

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。