Skip to content

Instantly share code, notes, and snippets.

@appleboy
Created October 3, 2013 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appleboy/6806323 to your computer and use it in GitHub Desktop.
Save appleboy/6806323 to your computer and use it in GitHub Desktop.
#!/bin/sh
script="index.php cli worker"
folder="/script_path/"
max_worker="5"
php_bin="/usr/bin/php"
count=0
current_count=$(ps aux | grep "index.php cli worker" | grep -v "grep" | wc -l)
if test $current_count -lt $max_worker
then
cd $folder
$php_bin $folder$script &
else
echo "The worker count has been limited."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment