Skip to content

Instantly share code, notes, and snippets.

@xurenlu
Created October 14, 2011 14:31
Show Gist options
  • Save xurenlu/1287279 to your computer and use it in GitHub Desktop.
Save xurenlu/1287279 to your computer and use it in GitHub Desktop.
运行一次
#!/bin/bash
# check daemon
check(){
cmd=$1
lines=`ps -ef | grep $cmd |grep -v grep |wc -l`
# if not found - equals to 1, start it
echo $lines
if [ $? -eq 0 ]; then
$cmd
else
echo "eq 0 - daemon found - do nothing"
fi
}
help(){
echo "" $0 " YOUR_COMMAND "
}
the_cmd="testing.php"
if [ -z $the_cmd ]; then
help
else
check $the_cmd
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment