In my Django app, I need to implement this “timer-based” functionality:
- User creates some jobs and for each one defines when (in the same unit the timer works, probably seconds) it will take place.
- User starts the timer.
- User may pause and resume the timer whenever he wants.
- A job is executed when its time is due.
This does not fit a typical cron scenario as time of execution is tied to a timer that the user can start, pause and resume.
What is the preferred way of doing this?
I used the probably simplest (crudest is more appropriate, I’m afraid) approach possible: 1. Wrote a model featuring the current position and the state of the counter (active, paused, etc), 2. A django job that increments the counter if its state is active, 3. An entry to the cron that executes the job every minute.
Thanks everyone for the answers.