1

I'm building a newsletter application and I want to implement a feature that will allow users to program when their message will be delivered. For example to be able to deliver a message at 12:32 PM on 01/02/2013. I read about events in MySQL, but this doesn't solve my problem.

The only solution that comes to mind is to set up a cron script to run every minute and check if there's a message programmed. If it is, then deliver the message and perform any additional tasks.

Any other idea?

2 Answers 2

2

Crontab is your friend. Examples of cron jobs

Sign up to request clarification or add additional context in comments.

4 Comments

Worth to say that if you don't have access in the server to run php scripts on command line, lynx is your friend too :)
So you're saying I should add a crontab entry with PHP every time a new message is programmed, right?
No just one cronjob that goes through the table checking for messages once a min and sends them dependant upon validation.
You could fire a queue reader hourly and sleep until the next event happens in the queue. If there are no events in the queue it could exit without waiting for the next event.
0

As an alternative to a cron job polling your mysql database every minute, you could try using a task queue like beanstalk which allows you to launch asynchronous jobs. It allows you to specify a delay before a task is run, so you could convert the time the user specifies that the job should be run to the relative delay. You could then provide an interface to the user to have control over the jobs that they scheduled, if they want to cancel them. Really, for this purpose, if there aren't many, many jobs that are going to be scheduled this way, and your mysql table is relatively small, it's probably simpler to go the mysql/cron route.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.