基於redis+mysql+php的簡單佇列實現
阿新 • • 發佈:2019-02-15
#!/bin/bash
#開啟
function start()
{
#先檢測程式是否已經開啟
pid=`ps -ef | grep "php -f mailQueue.php" | grep -v grep | awk '{print $2}'`
if [ "$pid" == "" ]
then
php -f mailQueue.php >> mailLog &
echo "程式啟動成功"
else
echo "程式已經開啟過"
fi
}
#關閉
function stop()
{
pid=`ps -ef | grep "php -f mailQueue.php" | grep -v grep | awk '{print $2}'`
if [ "$pid" == "" ]
then
echo "程式未開啟"
else
kill -9 $pid
echo "程式關閉成功"
fi
}
#檢視開啟狀態
function status()
{
pid=`ps -ef | grep "php -f mailQueue.php" | grep -v grep | awk '{print $2}'`
if [ "$pid" == "" ]
then
echo "程式未開啟"
else
echo "程式執行中,pid: $pid"
fi
}
#主程式
case "$1" in
"start")
start
;;
"stop" )
stop
;;
* )
echo "引數錯誤! Usage: mailQueue [start|stop|status]"
;;