0

I'm aware of cron jobs to execute commands at a certain time, but what if that time is not constant? For instance, suppose a user asks for a reminder email exactly 1hr after signing up for something, is there an easy way to go about doing this?

Timing is critical. I am actually trying to create AI that will essentially act on its own but only at variable points during the day. Any help would be appreciated!

3 Answers 3

2

You can use at to schedule jobs for specific times. cron is for repeating jobs, at is for one-shot/oddball interval ones. Both have a resolution of 1 minute, though, so you can't specify a start period with seconds granularity.

The command's available on both Unix/Linux and Windows.

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

1 Comment

Marc - Good solution. Why reinvent the wheel!
1

Here a workable flow:

  1. user Requests email in 1 hour
  2. You insert into the a table action (action_id, time)
  3. On the PHP server create a cron job to check the action in the action table every minute, then do the action that need to be done at that time

That is a simple example from the request. It might get a bit more complex then that.

EDIT : this suggestion might be good only if you need to be very precise with the time management!

2 Comments

I was thinking about creating a cron job to check a database every minute or so, but I thought that might be taxing to the server. Is that the most efficient way?
That depens on your context. How many action? times How many users? the processing required by action. All these questions might help you decides if the suggessted workflow is good.
1

if you dont wanna use the cron triggers and you are not comfortable with them here are two php scheduling libraries..

1) http://www.php.brickhost.com/

2) http://www.phpjobscheduler.co.uk/

Try them if you like:

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.