Last active
August 29, 2015 14:24
-
-
Save moolex/3ca216d1aa7b6c3ada2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# supervisor job control | |
function job() | |
{ | |
if [ $# -gt 0 ]; then | |
cmd=$1 | |
else | |
cmd="status" | |
fi | |
if [ $# -lt 2 ] && [ $cmd != "status" ]; then | |
echo "请输入任务名称,多个关键词使用空格隔开" | |
return | |
fi | |
status=`sudo supervisorctl status` | |
for (( i = 2 ; i <= $# ; i ++ )) | |
do | |
status=`grep ${!i} <<< "$status"` | |
done | |
if [ $cmd = "status" ]; then | |
echo "$status" | |
else | |
tasks=`awk '{print $1}' <<< "$status"` | |
for task in $tasks | |
do | |
sudo supervisorctl $cmd $task | |
done | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment