Skip to content

Instantly share code, notes, and snippets.

@alex88
Last active March 31, 2017 21:57
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 alex88/f2c337ea57693c2e97bff2ecc64dc8b2 to your computer and use it in GitHub Desktop.
Save alex88/f2c337ea57693c2e97bff2ecc64dc8b2 to your computer and use it in GitHub Desktop.
<?php
echo "Start" . PHP_EOL;
sleep(60);
echo "Stop" . PHP_EOL;
#!/usr/bin/env bash
_cleanup() {
echo "Caught SIGTERM signal! Sending to child and exiting loop"
kill -s INT "$child"
wait
exit
}
trap _cleanup SIGINT SIGTERM
while true; do
php script.php &
child=$!
wait "$child"
done
echo "Done, exiting"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment