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

如何使用oc或kubectl命令仅获取最近5分钟的事件?

获取最近5分钟的Kubernetes/OpenShift事件

是的,kubectl和oc都支持筛选最近指定时间段的事件,你可以通过--since参数实现需求:

  • 使用kubectl的命令:
kubectl get events --since=5m
  • 使用oc的命令:
oc get events --since=5m

额外说明

  • --since参数支持多种时间单位:s(秒)、m(分钟)、h(小时)、d(天),比如2h代表最近2小时的事件
  • 如果需要更精准的筛选(比如只看警告类型事件、特定命名空间的事件),可以结合-o json和jq做二次过滤,示例:
oc get events --since=5m -o json | jq '.items[] | select(.type == "Warning")'

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 01:46:09