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

Linux环境下Jenkins日志查询:找不到jenkins.wrapper.log时如何查启停时间

Hey there! I totally get it—sometimes the log files you expect aren't where you think they are. Let's walk through several reliable ways to track Jenkins' start/stop times on your Linux VM:

方法1:利用Systemd日志(最常用)

If your Jenkins is managed via a systemd service (standard on most modern Linux distros), the journalctl command is your go-to:

  • View the full Jenkins service log:
    journalctl -u jenkins.service
    
  • Filter for explicit start/stop entries to save time:
    journalctl -u jenkins.service | grep -E "Started Jenkins|Stopped Jenkins"
    
  • Narrow it down to a specific time range, like the last 24 hours:
    journalctl -u jenkins.service --since "24 hours ago" | grep -E "Started|Stopped"
    
方法2:Check Jenkins' native log file

Jenkins writes core runtime logs to a default path (varies by distro):

  • Common locations:
    • /var/log/jenkins/jenkins.log (Debian/Ubuntu-based systems)
    • /var/lib/jenkins/logs/jenkins.log (some RHEL/CentOS setups)
  • Search for key start/stop markers:
    grep -E "Jenkins is fully up and running|Shutdown started" /var/log/jenkins/jenkins.log
    

You’ll see lines like "Jenkins is fully up and running" on startup, and "Shutdown started" when the service stops.

方法3:Query the running Jenkins process start time

If Jenkins is currently running, you can pull its start time directly from the process:

  1. First get the Jenkins PID:
    ps -ef | grep jenkins | grep -v grep
    
  2. Use the PID to get the exact start time:
    ps -o lstart= -p <JENKINS_PID>
    
    Or use stat for another format:
    stat /proc/<JENKINS_PID> | grep Birth
    
方法4:Jenkins Built-in API (only works if service is running)

If Jenkins is up, you can use its API to get uptime and calculate the start time:
Visit http://<your-jenkins-url>:<port>/api/json and look for the uptimeMillis field (milliseconds Jenkins has been running). Subtract this from the current time to get the start timestamp.
For a command-line approach with curl and jq:

CURRENT_TIME=$(date +%s%3N)
UPTIME=$(curl -s http://localhost:8080/api/json | jq '.uptimeMillis')
START_TIME=$(( (CURRENT_TIME - UPTIME) / 1000 ))
date -d @$START_TIME

Note: If Jenkins has authentication enabled, add your credentials to the curl command like curl -u username:password ...

方法5:System process audit logs (requires extra tools)

If you have the acct package installed, use lastcomm to view Jenkins process history:

lastcomm jenkins

This shows when Jenkins processes started and how long they ran—just make sure the acct service is enabled first.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 03:48:15