You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查看Job的已调度运行时间及下次运行时间视图?

Hey there! Let's break down how to get both the scheduled runtime history and next run time views for your jobs, depending on the scheduling tool you're using. Here's what you need to know:

获取Job的已调度运行时间视图

The approach varies based on the scheduling system you're working with:

Quartz Scheduler

  • API/Database Query: You can pull historical run times using Quartz's built-in database tables. For example, query the QRTZ_FIRED_TRIGGERS table to get details like fire time and scheduled time:
    SELECT job_name, fire_time, scheduled_fire_time, status 
    FROM QRTZ_FIRED_TRIGGERS 
    ORDER BY fire_time DESC;
    
    If you're using the Quartz API, you can fetch JobExecutionContext records to retrieve runtime details programmatically.
  • Management Console: Tools like QuartzDesk or the official Quartz UI provide a ready-to-use view of all past job runs, including start/end times and execution status.

Linux Cron Jobs

  • System Logs: Check your system's cron logs (usually /var/log/cron or /var/log/syslog) to find when your jobs ran. Filter with grep to target your specific job:
    grep "your-job-command" /var/log/cron
    
  • Custom Logging: If your cron job doesn't log by default, modify the cron entry to redirect output to a log file with timestamps:
    */5 * * * * /path/to/your/job.sh >> /var/log/your-job.log 2>&1 && echo "Ran at $(date)" >> /var/log/your-job.log
    

Kubernetes CronJobs

  • List Historical Jobs: Use kubectl to list all jobs triggered by your CronJob, sorted by creation time:
    kubectl get jobs --selector=app=your-cronjob-name --sort-by=.metadata.creationTimestamp
    
  • Pod Runtime Details: For more granular runtime data, check the logs of the pods associated with each job:
    kubectl logs <pod-name>
    
获取Job的下次运行时间视图

Again, here's how to do it across common tools:

Quartz Scheduler

  • Database Query: Pull the next fire time from the QRTZ_TRIGGERS table:
    SELECT job_name, next_fire_time 
    FROM QRTZ_TRIGGERS 
    WHERE job_name = 'YourJobName';
    
  • API/UI: Use the Quartz API's Trigger.getNextFireTime() method, or view the next run time directly in your Quartz management console.

Linux Cron Jobs

  • Use cronnext: Install the cronnext tool and pass your cron expression to get the next run time:
    cronnext "0 1 * * *"
    
  • Manual Calculation: If you don't want to install tools, you can calculate based on the cron expression rules (e.g., */5 * * * * means every 5 minutes, so next run is 5 minutes from now).

Kubernetes CronJobs

  • Describe the CronJob: Run this command to see the Next Schedule field in the output:
    kubectl describe cronjob your-cronjob-name
    
  • JSONPath Query: For a quick view, use JSONPath to extract just the next schedule time:
    kubectl get cronjob your-cronjob-name -o jsonpath='{.status.nextScheduleTime}'
    

内容的提问来源于stack exchange,提问作者Darkloud

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:40:20