Jump to content

ASync Process in PHP


mbrown

Recommended Posts

I am creating a PHP application that the HOA board will use to do some online voting between the board. That being said I would like to have an async job run every 24 hours at 6:00p.m. that would see what motions users have not voted on and e-mail them to let them know they need to vote on it.

 

Any suggestions would be greatly appreicated

Link to comment
Share on other sites

That's the idea. Although if this will be your first cron task, I suggest you write a script to do all the work while interacting with your console until you have it debugged. Use your email address to prove it out with results info and then eliminate any debugging outputs before setting it up to be a cron job.

 

I use an email to do my debugging of cron tasks. I output all my debug info to a separate message body and then send out the debug email to my address to test my program and watch what it is doing. Once I'm through I disable the debugging email by turning off a switch in the top of the script.

Link to comment
Share on other sites

  • 3 weeks later...

You simply create an email - plain text is good - that contains the output of what you are trying to do in your script. Show variables as the script works along to ensure that it is doing what you expect. I then send the email to myself at the end.

You can also use your address to send the 'real' output to yourself to ensure that it is sending the correct output. You can also avoid all of this simply by writing an ordinary script that outputs to the client until you get it right. Then you comment our the debugging echo statements and enable the email activity. Use a switch to control the debugging and another switch to control the actual email outputs.

 

Ex.

 

if ($debug)

echo (something to help debug)

..

..

..

if ($debug

echo (something more to help debug)

..

..

..

if ($send_emails)

(call a function to send the production emails)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.