Well basically I may want to execute a script that may take as much as 1 hours as well.
What I really want to do is Send SMS to my users using a third party API. So
It's not the best options to use set_time_limit(0), because that'd means it'll run indefinitely even if you have a bug and your script enters an infinite loop.
Instead, if you estimate each SMS is going to take 5 seconds, use this approach:
while( $there_are_more_sms_to_be_sent ){
set_time_limit(30); // enough spare time, just in case.
// Do your sending, blah blah
}
That way, the time limit will be sequentially updated to 30 seconds. Of course you might have the infinite loop problem with that single while, but if you have other calls inside that while that limit will prevent those calls to be to blame.