Skip to content

Instantly share code, notes, and snippets.

@hjue
Created July 23, 2015 07:37
Show Gist options
  • Select an option

  • Save hjue/f19210fd48db864ffc38 to your computer and use it in GitHub Desktop.

Select an option

Save hjue/f19210fd48db864ffc38 to your computer and use it in GitHub Desktop.
run php code
#!/bin/bash
ulimit -f 64 -m 64 -t 2 -u 128
[[ ! -d /out/$1/ ]] && mkdir /out/$1/ || chmod u+w /out/$1/
for bin in /bin/php-*
do
echo $bin - $1
nice -n 15 sudo -u nobody $bin -c /etc/ -q "/in/$1" &>/out/$1/${bin##*-} & PID=$!
( sleep 3.1; kill -9 $PID 2>/dev/null ) &
wait $PID
ex=$?
sf=/out/$1/${bin##*-}-exit
[[ $ex -eq 0 && -f $sf ]] && rm $sf
[[ $ex -ne 0 ]] && echo -n $ex > $sf
done
chmod u-w /out/$1/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment