#linux查询进程是否存在,如果不存在则启动该进程:
#!/bin/bash
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0`
result=$(echo $ps_out | grep "$1")
if [[ "$result" != "" ]];then
echo "Running"
else
echo "Not Running"
/app/module/spark/sbin/start-thriftserver.sh
fi

 

root用户授权开启定时任务:
echo admin> /etc/cron.allow

admin用户设置定时任务:
crontab -e

定时任务设置为每一分钟执行一次:
*/1 * * * * /home/admin/thriftserver.sh