使用Launchd和email administrator禁用heartbeat
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Launchd和email administrator禁用heartbeat相关的知识,希望对你有一定的参考价值。
Obviously you need to have heartbeatd handled by Launchd
#!/bin/bash ### # Stop heartbeatd so that failoverd initiates IPFailover # leaving network interfaces intact. ### # Setup mail ### C_NAME=`/usr/sbin/scutil --get ComputerName` NOTIFY="[email protected]" WARNING="Heartbeatd has been halted - Failover process initiated" ### # End Setup mail ### HEARTD=`/bin/ps -axcu | /usr/bin/grep -i heartbeatd > /dev/null; echo $?` if [ ! ${HEARTD} -eq 0 ]; then echo "heartbeatd is not running - uh oh..." /usr/bin/logger "FAILOVER: heartbeatd is not running - uh oh..." echo From: ${C_NAME} - ${WARNING} > /tmp/heartbeat_warning.txt | mail -s "FAILOVER PROCESS: Heartbeatd was not running" ${NOTIFY} < /tmp/heartbeat_warning.txt else launchctl unload /Library/LaunchDaemons/uk.ac.rave.heartbeatd.plist while [ $(/bin/ps -axcu | /usr/bin/grep -i heartbeatd > /dev/null; echo $?) -eq 0 ]; do echo "Halting heartbeatd" /usr/bin/logger "FAILOVER: Halting heartbeatd" /bin/sleep 5 done echo "heartbeatd has been halted" /usr/bin/logger "FAILOVER: heartbeatd has been halted" rm -f /var/run/heartbeatd.pid echo From: ${C_NAME} - ${WARNING} > /tmp/heartbeat_warning.txt | mail -s "FAILOVER PROCESS: Heartbeat halted - failover in process" ${NOTIFY} < /tmp/heartbeat_warning.txt fi exit 0
以上是关于使用Launchd和email administrator禁用heartbeat的主要内容,如果未能解决你的问题,请参考以下文章
Mac下用Launchd实现使用rc.local执行开机启动命令
Mac使用Launchd命令行lauchctl操作服务的简单用法