I have a script test.php. If it works correctly, its execution time is 5 seconds. If not correct, it will freeze.
How can I control it - I want skip it if it executes more then 10 seconds.
#!/bin/bash
while true do
now=$(date +"%T")
echo "Current time : $now";
php-cgi /home/dev/test/test.php
echo 'Waiting 120 seconds';
sleep 120;
done
Try timeout
:
timeout 10s php-cgi /home/dev/test/test.php