效果(x:居然不能帖图),我没图床..直接上代码
// ==UserScript== // @name xxl-job 执行时间计算 // @namespace Violetmonkey Scripts // @match http://*/joblog* // @grant none // @version 1.0 // @author - // @description 2024/11/12 17:25:38 // ==/UserScript== // 获取表格中的所有行 function execute(){ var rows = document.querySelectorAll('#joblog_list tbody tr'); if(!rows){ return } // 遍历每一行 rows.forEach(function(row) { // 获取调度时间和执行时间的元素 var scheduleTimeElement = row.querySelector('td:nth-child(2)'); var executeTimeElement = row.querySelector('td:nth-child(5)'); if(!executeTimeElement.innerText){ return } if(executeTimeElement.innerText.indexOf("|") != -1){ return } // 获取调度时间和执行时间的文本内容,并将其转换为 Date 对象 var scheduleTime = new Date(scheduleTimeElement.innerText); var executeTime = new Date(executeTimeElement.innerText); // 计算时间差(单位:毫秒) var timeDifference = executeTime - scheduleTime; console.log(timeDifference); var secOnds= parseInt(timeDifference / 1000); // 将时间差显示在执行时间后面 var addText = seconds<60?' || ' + seconds + '秒' : ' || ' + '<span style="color: red">' + seconds + '</span>' + '秒' executeTimeElement.innerHTML += addText; }) } setInterval(execute,800)
1 spritecn OP 腾讯云 AI 代码助手写的,改了改 |
![]() | 2 miaotaizi 331 天前 我的理解, 这种任务调度工具执行的任务是不是应该是简单任务? 耗时的任务用这种工具去做还靠谱吗? |
4 zeonluang 331 天前 有些任务, xxl job 只作为触发, 实际异步或父子执行, 日志没法监控 |
![]() | 5 wolfie 330 天前 应该用 APM ,用 xxl job 触发做筛选。 |