Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: sleep function php

  1. #1

    sleep function php

    Hi everyone,

    I was wondering if the sleep function when used consume much processing power or is it a bad practice to use it as i want a function to kick in every day at a certain time and then sleep and wait untill the next day?

    e.g. function runs and check the DB to see whether or not it must update / delete data. So function for e.g. runs everyday at 00:00 and sleep until it must run again.

    Please does anybody can put me on the right track.

    Regards,

    Jerome Chevreau

  2. #2
    Sleep pauses the script for an x amount of seconds, there is no way it is going to use any resources during that wait.

    Altho sleep is a great function, im pretty sure its not the way to go for this purpose, try using crontab(unix)/scheduler(windows) instead.. and schedule your script to run every day at midnight.

    Crontabs - http://crunchbang.org/archives/2007/...-crontab-file/
    Windows Scheduler - http://manual.b2evolution.net/Set_up...Scheduled_Task

    You can never underestimate the stupidity of the general public.

  3. #3
    it is a bad idea to use sleep() for delayed output effects as

    1) you have to flush() output before you sleep

    2) depending on your setup flush() will not work all the way to the browser as the web server might apply buffering of its own or the browser might not render output it thinks not to be complete

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012