Search code examples
phpcronjobsflush

PHP Cron Job Flush/OB Flush Needed?


I have a lot of images or will. I am looking to periodically change the name of the images with a cron job.

// mysql query -> select all images
$i = 0;
while($i < $num_images){
            // update image file name
            // update image file name in mysql DB
$i++;
}

Should I, can I, do I need to, use ob_end_flush(), ob_start(), ob_end_clean() to help insure correct functionality? I'm not outputting anything but there is a lot of images.

NOTE: I am dealing with a large number of images. The script takes a long time to finish. I was trying to find a way to quicken the setting of the MySQL databases. As you can see I am using a cron job. I can output text updates and my understanding states that these functions flush the php memory, but I wasn't sure if it would make a difference in the real-time file and database update. The outcome of the above was that it was updating in chunks hense the thought that flushing the memory to finalize each file and database update set would make it ideal if it were possible. (I know more now about my situation so I thought I'd make this clearer as it is confusing)


Solution

  • Output buffer will have no effect here. Output buffers are designed to control when output (echo or print statements) is sent. The renaming of an image will occur as soon as you execute the statement - irregardless of what output your script sends.

    http://php.net/manual/en/intro.outcontrol.php