Skip to content

Instantly share code, notes, and snippets.

@ziggear
Created May 6, 2013 06:01
Show Gist options
  • Save ziggear/5523572 to your computer and use it in GitHub Desktop.
Save ziggear/5523572 to your computer and use it in GitHub Desktop.
#说明
#1. [ -z "$1" ] 判断字符串是否为空
#2. [ $1 == "off" ] && foo 简化的if写法
#3. nohup foo & 让程序在后台运行
#4. xargs 让管道的输出作为args (正常情况管道的输出是作为标准输入)
function goagent() {
if [ -z "$1" ] ; then
echo "Args too few"
echo "e.g. goagent on"
else
[ $1 == "on" ] && nohup python /path/to/goagent/local/proxy.py &
[ $1 == "off" ] && ps | grep python | awk 'NR==1{print $4}' | xargs killall $1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment