commit | author | age
|
90c639
|
1 |
#!/bin/bash |
Z |
2 |
|
|
3 |
basepath=$(cd `dirname $0`; pwd) |
|
4 |
chmod a+x "$basepath/yii" |
|
5 |
command="$basepath/yii queue/listen 1" |
|
6 |
command2="$basepath/yii queue3/listen 1" |
|
7 |
command4="$basepath/yii queue4/listen 1" |
|
8 |
|
|
9 |
result=$(ps -ef | grep "`echo $command`" | grep -v "grep") |
|
10 |
result2=$(ps -ef | grep "`echo $command2`" | grep -v "grep") |
|
11 |
result4=$(ps -ef | grep "`echo $command4`" | grep -v "grep") |
|
12 |
|
|
13 |
if [ ! -n "$result" ] |
|
14 |
then |
|
15 |
echo "Starting the process." |
|
16 |
str=$(nohup $command >/dev/null 2>&1 &) |
|
17 |
echo -e "\033[32mOk.\033[0m" |
|
18 |
else |
|
19 |
echo "The process has been started." |
|
20 |
fi |
|
21 |
|
|
22 |
if [ ! -n "$result2" ] |
|
23 |
then |
|
24 |
echo "Starting the process3." |
|
25 |
str=$(nohup $command2 >/dev/null 2>&1 &) |
|
26 |
echo -e "\033[32mOk.\033[0m" |
|
27 |
else |
|
28 |
echo "The process3 has been started." |
|
29 |
fi |
|
30 |
|
|
31 |
if [ ! -n "$result4" ] |
|
32 |
then |
|
33 |
echo "Starting the process4." |
|
34 |
str=$(nohup $command4 >/dev/null 2>&1 &) |
|
35 |
echo -e "\033[32mOk.\033[0m" |
|
36 |
else |
|
37 |
echo "The process4 has been started." |
|
38 |
fi |
|
39 |
|
|
40 |
result=$(crontab -l|grep -i "* * * * * $basepath/queue.sh"|grep -v grep) |
|
41 |
if [ ! -n "$result" ] |
|
42 |
then |
|
43 |
echo -e "\033[32mCreating queue crontab.\033[0m" |
|
44 |
echo "Export crontab data" |
|
45 |
crontab -l > createcrontemp |
|
46 |
echo "Add new crontab line" |
|
47 |
echo "* * * * * $basepath/queue.sh" >> createcrontemp |
|
48 |
echo "Import crontab data" |
|
49 |
crontab createcrontemp |
|
50 |
echo "Delete temp file" |
|
51 |
rm -f createcrontemp |
|
52 |
echo -e "\033[32mCreating queue crontab success.\033[0m" |
|
53 |
else |
|
54 |
echo "The queue crontab has been add ." |
|
55 |
fi |