When dealing with Jenkins on macOS, you might encounter a situation where killing the Java process simply results in it respawning under a new PID. This occurs because the process is managed by launchd
, macOS's init system and service manager.
$ ps -eaf
UID PID PPID C STIME TTY TIME CMD
216 1143 1 0 0:01.65 ?? 0:04.03 /usr/bin/java -jar /Applications/Jenkins/jenkins.war
0 1 0 0 0:06.09 ?? 0:06.19 /sbin/launchd
The key observation here is the PPID (Parent Process ID) of 1, which indicates launchd
is managing this process.
Method 1: Using launchctl to Unload the Service
First, identify the Jenkins service label:
launchctl list | grep -i jenkins
Common labels might include jenkins
, org.jenkins-ci
, or similar. Then unload it:
launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Method 2: Force Removal of Launch Agent
Locate and remove the plist file:
sudo rm /Library/LaunchDaemons/org.jenkins-ci.plist
Method 3: Combined Kill Approach
For immediate termination while preventing respawn:
# Find all Jenkins-related processes
pgrep -f jenkins | xargs kill -9
# Then unload the service
launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
To permanently disable Jenkins from auto-starting:
sudo launchctl disable system/org.jenkins-ci
sudo launchctl bootout system/org.jenkins-ci
After performing these actions, verify the process is truly gone:
ps -ef | grep jenkins
launchctl list | grep jenkins
If you need to temporarily stop Jenkins without uninstalling, consider using:
sudo launchctl stop org.jenkins-ci
When dealing with Jenkins running as a background service on macOS, you might encounter a frustrating scenario where the process keeps respawning after being killed. This happens because launchd (PID 1) manages the process lifecycle. Here's what's happening under the hood:
$ ps -eaf | grep jenkins
216 1143 1 0 0:01.65 ?? 0:04.03 /usr/bin/java -jar /Applications/Jenkins/jenkins.war
The key observation is the parent process ID (PPID) being 1 (launchd). This indicates the process is managed by macOS's service management framework.
On macOS, launchd acts as the first process (like systemd on Linux) and manages daemons. When you simply kill
the Jenkins process, launchd detects the termination and restarts it according to its configuration.
Method 1: Unload the launchd Service
First identify the launchd plist file associated with Jenkins:
# Check common locations
ls /Library/Launch*/ | grep -i jenkins
# Or search the whole system
sudo find / -name "*jenkins*.plist" 2>/dev/null
Once located, unload it:
sudo launchctl unload /path/to/jenkins.plist
Method 2: Stop via Jenkins CLI
If Jenkins is running with CLI access:
java -jar jenkins-cli.jar -s http://localhost:8080/ safe-shutdown
Method 3: Force Remove (Not Recommended)
As last resort, remove the war file and kill Java:
sudo rm /Applications/Jenkins/jenkins.war
sudo killall java
For permanent removal, also disable the launchd service:
sudo launchctl disable system/jenkins
sudo launchctl bootout system/jenkins
Remember to backup your Jenkins data before performing these operations if you plan to reinstall later.