Skip to content

Instantly share code, notes, and snippets.

@moolex
Last active August 29, 2015 14:24
Show Gist options
  • Save moolex/3ca216d1aa7b6c3ada2a to your computer and use it in GitHub Desktop.
Save moolex/3ca216d1aa7b6c3ada2a to your computer and use it in GitHub Desktop.
#!/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