Hello,
set_time_limit() works in CLI scripts.
<?php
set_time_limit(1); //in seconds
for (;;);
?>
After one second returns with the following error message:
PHP Fatal error: Maximum execution time of 1 second exceeded in \
/home/stivlo/test.php on line 4
Initially I tried with sleep() and the time limit doesn't get applied. As @Jon suggested, using a real computation, like an infinite loop works.
Hope it helps!!