列出计划作业 / 查看其状态
Oracle
SELECT job_name, enabled, state, last_start_date, next_run_date
FROM dba_scheduler_jobs
ORDER BY next_run_date;
-- Run history: SELECT job_name, status, actual_start_date, run_duration
-- FROM dba_scheduler_job_run_details ORDER BY log_date DESC;dba_scheduler_jobs 显示已定义的作业及其状态;dba_scheduler_job_run_details 显示历史运行的成功/失败结果。
PostgreSQL
SELECT jobid, schedule, command, nodename, active FROM cron.job;
-- Run history:
SELECT jobid, status, return_message, start_time, end_time
FROM cron.job_run_details ORDER BY start_time DESC LIMIT 20;使用 pg_cron 时,cron.job 列出已定义的作业,cron.job_run_details 给出每次运行的状态和返回消息。
MySQL
SELECT event_schema, event_name, status, interval_value, interval_field, last_executed
FROM information_schema.events
ORDER BY last_executed DESC;information_schema.events 列出已定义的事件、其状态(ENABLED/DISABLED)及最近执行时间。
SQL Server
SELECT j.name, j.enabled, h.run_status, h.run_date, h.run_time
FROM msdb.dbo.sysjobs j
LEFT JOIN msdb.dbo.sysjobhistory h ON h.job_id = j.job_id AND h.step_id = 0
ORDER BY h.run_date DESC, h.run_time DESC;msdb.dbo.sysjobs 给出已定义的 Agent 作业,sysjobhistory 给出运行历史和结果(run_status)。
MongoDB
# Not applicable: there is no built-in scheduler, so there are no jobs to list. If Atlas Triggers are used, view them in the Atlas UI/API.Community MongoDB 没有作业表;Atlas Triggers 在 Atlas 界面中管理。
Redis
# Not applicable: Redis has no concept of scheduled jobs, so there are no jobs to list.Redis 不含作业调度器;没有可列出的作业。
Elasticsearch
GET _slm/policy
GET _ilm/policy
// For Watcher states: GET _watcher/stats and GET _watcher/_query/watches_slm/policy 列出快照策略,_ilm/policy 列出生命周期策略,_watcher/stats 显示 Watcher 的执行状态。