linux - kill function after specific time in php? -
i have 5 exec()
function in script.i want if function not give response in given time function kill , next function starts execution.
<?php exec("timeout 5 /usr/local/bin/wrun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime); exec("timeout 5 /usr/local/bin/trun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime); exec("timeout 5 /usr/local/bin/drun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat'",$uptime); ?>
in timeout
argument not working.please correct or gives alternative method.
create bash script caller.sh , execute via exec. command automatically killed after 5 seconds.
caller.sh
#!/bin/sh /usr/local/bin/wrun 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat' & sleep 5 kill $! 2>/dev/null && echo "killed command on time out"
php
exec("caller.sh",$uptime);
Comments
Post a Comment