Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,493 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,694 people online right now. Registration is fast and FREE... Join Now!




PHP and Cron - can PHP modify the cron timing?

 
Reply to this topicStart new topic

PHP and Cron - can PHP modify the cron timing?

a575606
5 Mar, 2008 - 07:10 PM
Post #1

New D.I.C Head
*

Joined: 5 Mar, 2008
Posts: 2

Hello everyone. I am using a cron job to manage my email list of about 12,000 emails. I send a monthly newsletter out. I have already set up a php script which runs via cron and sends to 30 emails at a time. When I send my newsletter, I set the cron job to run every minute until the newsletter is done sending. However, for the rest of the month, I don't need the script to run every minute, so I set the cron to check every 3 to 6 hours.

My question is, is it possible to have cron set to check every 3 or 6 hours, but when it finds emails in the queue, it adjusts itself to run every minute until the emails are complete, then readjusts itself to go back to checking every 3 or 6 hours?

Thank you for your help.
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: PHP And Cron - Can PHP Modify The Cron Timing?
5 Mar, 2008 - 07:12 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,465



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(a575606 @ 5 Mar, 2008 - 08:10 PM) *

My question is, is it possible to have cron set to check every 3 or 6 hours, but when it finds emails in the queue, it adjusts itself to run every minute until the emails are complete, then readjusts itself to go back to checking every 3 or 6 hours?

Thank you for your help.

Just make a flag when the process starts (touch in_process.flg <- for example) & when the script is launched by cron, check for the existence of that file. When the process is finished, have it remove the flag.
User is online!Profile CardPM
+Quote Post

a575606
RE: PHP And Cron - Can PHP Modify The Cron Timing?
5 Mar, 2008 - 07:39 PM
Post #3

New D.I.C Head
*

Joined: 5 Mar, 2008
Posts: 2

QUOTE(no2pencil @ 5 Mar, 2008 - 08:12 PM) *

Just make a flag when the process starts (touch in_process.flg <- for example) & when the script is launched by cron, check for the existence of that file. When the process is finished, have it remove the flag.


Hi No2Pencil. I'm not quite sure what you mean exactly. I've been using php for several years but not done much automating before. This is the idea I had. Will this work:

CODE

$result = $oNewsletter_Delivery->getList();

while (mysql_num_rows($result) > 0){

    while($myrow=mysql_fetch_row($result)){
    
        // SEND THE NEWSLETTER
        
        $oNewsletter_Delivery->delete($myrow[0]);
    }// end while($myrow=mysql_fetch_row($result)
// INSERT A PAUSE OF 30 seconds
        sleep(30);
$result = $oNewsletter_Delivery->getList();

    
}// end while(mysql_num_rows($result)>0);


This post has been edited by a575606: 5 Mar, 2008 - 07:44 PM
User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: PHP And Cron - Can PHP Modify The Cron Timing?
6 Mar, 2008 - 05:58 AM
Post #4

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

he saying, make a timer file?

can just have it update the tame as needed, exit if it not the time you want.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 07:54PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month