1

I want to find a way to execute increment for every 5 mins, please help

example
for ($i=1;$i<=11;$i++) {
echo $i;
}

print

  1. after 5min
  2. after 5min
  3. after 5min
  4. after 5min
  5. after 5min ......
1
  • The wisdom of doing this is somewhat questionable. Can you tell us why you want to delay execution? Honestly, this sounds like more of a job for a scheduler (see the reference to cron below) than for a loop. Commented Apr 30, 2012 at 19:57

4 Answers 4

4
for ($i=1;$i<=11;$i++) {
sleep(300);
echo $i;
}
Sign up to request clarification or add additional context in comments.

Comments

4

sleep

Or, do you want a cron job?

1 Comment

@will.i.am sleep(300) will hold execution for 5 minutes.
1

If you want to run a script every 5 minutes, you should use a cronjob. If you are using a control panel such as cPanel or DirectAdmin you can add the cronjob. If you have (only) SSH access to the machine then use the crontab -e command and add the following line:

*/5 * * * * /usr/bin/php /location/of/the/script.php

If you /usr/bin/phpis not your PHP path, then create a script and use <?php phpinfo(); to find out what the location actually is.

Comments

1

Use Cron Jobs or Sleep Function in php

if the cron jobs is disable on your server than use free online cron jobs service

http://www.onlinecronjobs.com/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.