gpt4 book ai didi

Check health of scheduled tasks?(是否检查计划任务的运行状况?)

转载 作者:bug小助手 更新时间:2023-10-28 21:19:34 26 4
gpt4 key购买 nike



We recently had an issue where a ColdFusion scheduled task didn't resume after a Windows upgrade and a CF server restart. Is there a way to monitor the health of scheduled tasks and be alerted if they are not running properly? Or would I need to write a task to parse the log files for that information?

我们最近遇到了一个问题,在Windows升级和CF服务器重新启动后,ColdFusion计划任务没有恢复。有没有办法监控计划任务的运行状况,并在它们运行不正常时发出警报?或者,我是否需要编写一个任务来解析日志文件中的信息?


更多回答
优秀答案推荐

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

您可以使用管理API来获取有关计划任务的信息。下面返回一个结构数组,其中包含有关每个计划任务的信息。然后,您可以遍历数组并查看last_run变量。



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


If you want to check that scheduled tasks are working at the most general level, one way is to schedule a "heartbeat" task, running as frequently as you wish. Set the task to update a counter, change a timestamp, send an email, trigger an "I'm alive" SMS every morning, add a log entry -- whatever makes sense. This won't tell you that all your tasks are running, but it will tell you that the server is alive, and the scheduled task system itself is working.

如果您想要检查计划的任务是否在最一般的级别上运行,一种方法是计划一个“心跳”任务,以您希望的频率运行。设置任务来更新计数器、更改时间戳、发送电子邮件、每天早上触发“我还活着”的短信、添加日志条目--任何有意义的事情。这不会告诉您所有任务都在运行,但它会告诉您服务器处于活动状态,计划的任务系统本身正在工作。



Another option is to funnel your tasks through a single point of entry -- a sort of front-controller for tasks. This delegates the setup and configuration of individual tasks to your code, rather than the CF Administrator. Your master task controller would include triggering code for each task. Schedule the controller to run at as frequently as needed -- so, one single task, rather than many. In the controller, something like this, perhaps every five minutes:

另一种选择是通过单一入口点收集任务--一种任务的前端控制器。这会将单个任务的设置和配置委托给您的代码,而不是CF管理员。您的主任务控制器将包括每个任务的触发代码。安排控制器按所需的频率运行--因此,只执行一个任务,而不是多个任务。在控制器中,大概每隔五分钟会出现这样的情况:



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 advantage to this approach is that you can express much richer go/no-go workflows -- have tasks run at semi-randomized frequencies, run tasks based on the success or failure of other tasks, etc. If you see/receive the heartbeat indicator, you know your task controller did in fact run.

这种方法的一个优点是,你可以表达更丰富的go/no-go工作流--让任务以半随机的频率运行,根据其他任务的成功或失败来运行任务,等等。



Another simple option. Enable the output file for each task and check these files by independent Cron job: if file was changed within required time span should mean that scheduler task was executed.

另一个简单的选择。为每个任务启用输出文件,并通过独立的Cron作业检查这些文件:如果文件在要求的时间跨度内更改,则应该意味着执行了调度程序任务。



The suggestion that the user gave for finding out what processes are running is brilliant.

用户给出的关于找出哪些进程正在运行的建议非常出色。


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

=创建对象(“Java”,“coldfusion.server.ServiceFactory”).getCronService().listall()/>


Using this, I found that when I moved the scheduled tasks from one server to another by copying the neo-cron.xml from one server to another many of the processes stopped processing. When I reviewed the processes using the scheduled task list, I noticed that the processes that WERE working didn't have encrypted passwords in the password field while the ones that DID NOT work had encrypted passwords that prevented the processes from running due to the fact that when the processes ran, it couldn't decrypt the passwords that were in the neo-cron.xml file (as they were from a different server and therefore the decryption didn't work). To solve this issue, I opened up the neo-cron.xml file and manually took out all of the passwords in the password section of each profile and then saved it and replaced the file with the passwords in it and then restarted the CF service. Once restarted, the processes started running again by themselves.

使用这个,我发现当我通过将neo-cron.xml从一个服务器复制到另一个服务器来将计划任务从一个服务器移动到另一个服务器时,许多进程停止处理。当我使用计划任务列表查看进程时,我注意到正在工作的进程在密码字段中没有加密密码,而那些不工作的进程则具有加密密码,这些密码阻止进程运行,因为当进程运行时,它无法解密neo-cron.xml文件中的密码(因为它们来自不同的服务器,因此解密不起作用)。为了解决这个问题,我打开了neo-cron.xml文件,手动取出每个配置文件密码部分的所有密码,然后保存它,并用其中的密码替换文件,然后重新启动CF服务。一旦重新启动,进程又开始自行运行。


I wanted to share this in case anyone else was having the same issue. If your tasks are kicking off after moving servers, check to make sure there aren't any passwords store in the neo-cron.xml file.

我想分享这一点,以防其他人也有同样的问题。如果您的任务是在移动服务器后启动的,请检查以确保neo-cron.xml文件中没有存储任何密码。


It took my ages to figure this out, so hopefully this helps someone else.

我花了很长时间才弄明白这一点,所以希望这能帮助其他人。


更多回答

We used this method, and every task that ran logged itself to a database table. So we were able to reconcile the times it was SUPPOSED to run versus the times they ACTUALLY ran.

我们使用这种方法,运行的每个任务都会记录到一个数据库表中。因此,我们能够协调它应该运行的时间和它们实际运行的时间。

Thanks. I wrote a quick CF script with this code to check the health of scheduled tasks. Right now it's running as a scheduled task itself, but I think I am going to port it over to a Windows task.

谢谢。我用这段代码编写了一个快速的CF脚本来检查计划任务的运行状况。现在它本身是作为计划任务运行的,但我想我会将其移植到Windows任务。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com