Reputation: 73
I want to achieve the following using Coldfusion 10 Scheduler.
If Task1 takes 10 minutes then it should again trigger in the 11th minute. If the next run takes 20 minutes, then it should trigger only at the 21st minute.
Please advice.
Upvotes: 3
Views: 748
Reputation: 773
This is possible, but not directly. A scheduled task can run another task in a "chain" but the task being chained has to be a task of type "chain". You can however, have a task run another through code.
Here is how you could set it up.
This should create an infinite loop. But be warned, this could result in some unwanted behavior. You will have to self manage errors and misfires. Also, if the chain cycle gets interrupted you will have to restart it.
You could setup a watcher task that makes sure the chain is running. If it appears to have failed you could call Task B to kick start the chain.
Upvotes: 2
Reputation: 1490
Here is a strategy to follow:
1) Create a table with a field to track if the script is in use. Example Table: ScheduleStatus, field: intInUse
2) Create your script. Have the first line of your script check to see if the field intInUse is null. If it is, then set it equal to 1 and run the rest of your script. If the field is not null, then skip to cfabort.
3) When your script is completed, mark the database field as NULL again.
4) Setup your scheduled task to run every minute. It will execute every minute, and if the script is in use, it will just abort.
There are probably other ways of doing this, by looping, etc.... but this is probably the easiest.
I use something similar for a queuing system of sending customized newsletters.
Upvotes: 1