I'm looking to run a ColdBox scheduled task 4 time...
# box-products
c
I'm looking to run a ColdBox scheduled task 4 times a day on weekdays between 4:30pm and 7:00pm. I was hoping to the below code but it seems to only run at the last time. Any thoughts on what I should actually do?
Copy code
task( "Warehouse: Tracking Numbers" )
					.call( ()=>getInstance( "tasks.warehouse_tasks" ).tracking_emails() )
					.everyDayAt( "16:30" )
					.everyDayAt( "17:00" )
					.everyDayAt( "18:30" )
					.everyDayAt( "19:00" )
					.onEnvironment( [ "production" ] );
d
Totally ignorant driveby comment... Do you need separate instances for each time?
c
That's my quick fix for now, but it seems like there should be the ability to do it in one. Like a startTime and endTime.
or chaining the way I have it
or .everyDay(interval,startTime,endTime)
.everyDay(30,14:00,18:00)
d
Yes that would be a more fluent API, but I'm glad the brute force version worked. Have you looked at the docs or the code (I haven't)? If all that's needed are the right arguments and right connecting-up, it might be something you could do yourself, either in an additional method or a pull request. But again I plead ignorance beyond the theoretical 🙂
c
Yup, I've gone over them. The options are pretty limited on each time/date function. Maybe on purpose. I also believe it is a new feature of ColdBox, so it is still maturing.
e
Each subsequent
everyDayAt
overrides the previous one. These are based off of Java’s
ScheduledExecutorService
which only give us the option to do 3 types of tasks: 1) one-offs, 2) one-off with a delay, and 3) fixed rate with initial delay. Since your pattern doesn’t nicely fall into these, I’d register four separate tasks.