The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

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.


    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 -
    Windows Scheduler -

    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 Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012