shell 小例

#!/bin/sh
insert_mysql()
{
passwd='passswrod'
/usr/local/bin/expect <<-EOF
set time 30
spawn ssh -p22 root@192.168.1.1
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}
expect "*#"
send "sh /root/jar/mysql_monitor.sh 1\r"
expect "*#"
send "exit\r"
interact
expect eof
EOF
}
list=(`yarn application --list |grep Stream | awk  '{print $2}'`)
if echo "${list[@]}" | grep -v "StreamAppUserData" &>/dev/null; then
    nohup start.sh >/dev/null 2>&1 &
    echo "`date` StreamAppUserData" >> /root/jar/log.log
    insert_mysql
fi
if echo "${list[@]}" | grep -v "StreamAppCrashData" &>/dev/null; then
    nohup start.sh >/dev/null 2>&1 &
    echo "`date` StreamAppCrashData" >> /root/jar/log.log
    insert_mysql
fi
echo `date` >> /root/jar/log.log
#!/bin/bash
echo `date` >> /var/lib/cloudera-scm-server/cdh_error.log
a=($@)
for i in ${a[@]};do
echo $i >>/var/lib/cloudera-scm-server/cdh_error.log
while read line
do
echo $line >>/var/lib/cloudera-scm-server/cdh_error.log
done < $i
done
passwd='xxxx'
/usr/local/bin/expect <<-EOF
set time 30
spawn ssh -p22 root@192.168.1.1
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}
expect "*#"
send "sh /root/jar/mysql_monitor.sh 2\r"
expect "*#"
send "exit\r"
interact
expect eof
EOF
#!/bin/bash
mysql -uroot -pxxx  <$1,'`date -d'1 hour' '+%Y-%m-%d %H:%M:%S'`',0)
EOF

你可能感兴趣的:(linux)