Check the performance of scheduled tasks?

We recently had a problem when a scheduled ColdFusion task did not resume after updating Windows and rebooting the CF server. Is there a way to monitor the performance of scheduled tasks and receive alerts if they do not work properly? Or do I need to write a task to analyze log files for this information?

+1
source share
3 answers

you can use admin api to get information about scheduled tasks. the following returns an array of structures with information about each scheduled task. you can then skip the array and look at the last_run variable.

<cfset arySchedTasks = createobject("java","coldfusion.server.ServiceFactory").getCronService().listall() /> 
+4
source

If you want to verify that scheduled tasks work at a very general level, one way is to plan a heartbeat task that works as often as you want. Set a task for updating the counter, change the timestamp, send an e-mail, turn on the SMS β€œI'm alive” every morning, add an entry to the log - which makes sense. This will not tell you that all your tasks are running, but it will tell you that the server is alive and the system of scheduled tasks is working.

Another option is to complete your tasks with a single entry point - a kind of front controller for tasks. This delegates the setting up and setting up individual tasks for your code, not the CF admin. The main task controller will include a startup code for each task. Plan for the dispatcher to work as often as needed - just one task, not many. In the controller, something like this, maybe every five minutes:

 Check the time/date, compare against set of tasks If time (or frequency) is A, run tasks P,Q,R, log success/failure If time is B, run tasks S,T, log success/failure If time is C, run tasks U,V,X, log success/failure Send heartbeat with success/failure codes for all relevant tasks 

One of the advantages of this approach is that you can express much richer go / no-go workflows - tasks are performed at semi-randomized frequencies, run tasks based on the success or failure of other tasks, etc. If you see / get a heart rate indicator, you know that your task controller has actually been executed.

0
source

Another easy option. Include an output file for each task and check these files using an independent Cron job: if the file has been modified within the required time period, this means that the scheduler task has completed.

0
source

Source: https://habr.com/ru/post/1414993/


All Articles