Introduction
Hello, I'm Yuto Takashi from TIELEC Inc. In this article, I'll introduce how to start, stop, and restart Jenkins, a popular CI/CD tool.
Since starting, stopping, and restarting Jenkins are not frequent operations, it's easy to forget how to do them. Additionally, there are multiple methods, and it can be confusing to know which operation to use in which situation.
This article organizes these Jenkins start, stop, and restart methods. If you're struggling with Jenkins operations, please read this article.
[Updated January 2026] Added information about the latest authentication methods (API tokens) and systemd.
Summary of Jenkins Start, Stop, and Restart Methods
Jenkins start, stop, and restart methods are classified into the following patterns:
- Operations on Jenkins Environment
- Directly operate Jenkins installed on Linux or Windows.
- Operations via Jenkins UI
- Perform operations by logging into Jenkins.
- Remote Operations of Jenkins
- Operate remotely via API or CLI.
Additionally, there are multiple modes for stopping and restarting Jenkins. This article covers this information.
Stop and Restart Modes
There are six modes for stopping and restarting Jenkins:
- exit (shutdown) - Stops Jenkins.
- safeExit (safeShutdown) - Puts Jenkins into Quiet mode, waits for existing builds to complete, then shuts down Jenkins.
- quietDown - Puts Jenkins into Quiet mode in preparation for restart. In this mode, Jenkins does not start any builds.
- cancelQuietDown - Cancels "quietDown".
- restart - Restarts Jenkins.
- safeRestart - Puts Jenkins into Quiet mode, waits for existing builds to complete, then restarts Jenkins.
About Authentication Methods (Important)
There have been important security changes regarding authentication methods when remotely operating Jenkins.
Using API Tokens (Recommended)
Writing passwords directly in commands is deprecated. Using API tokens is strongly recommended for the following reasons:
- Risk of passwords remaining in command history
- Risk of damage escalation due to password reuse
- Issues from a security audit perspective
How to Obtain API Tokens
- Log in to Jenkins
- Click your username in the upper right corner
- Click "Configure"
- In the "API Token" section, click "Add new Token"
- Enter a token name and click "Generate"
- Copy the generated token (it will only be displayed once, so be careful)
Types of Authentication Methods
When using Jenkins CLI or API, the following authentication methods are available:
1. Specify API token directly
-auth USERNAME:API_TOKEN
2. Use environment variables
export JENKINS_USER_ID=username
export JENKINS_API_TOKEN=your_api_token
3. SSH public key authentication (disabled by default, requires configuration)
This article uses API tokens in the following command examples.
Start, Stop, and Restart Execution Patterns
Operations on Jenkins Environment
Unix-based Environments
For environments like Ubuntu or Fedora, you can operate as follows.
Note: Starting with Jenkins 2.335 and 2.332.1, the package is configured with systemd (migrated from the older System V init).
These operations forcibly stop, start, or restart Jenkins. If you want to wait for currently running Jenkins jobs to complete, use quietDown or safeRestart via URL or API as described later.
start
sudo systemctl start jenkins
stop
sudo systemctl stop jenkins
restart
sudo systemctl restart jenkins
status (check status)
sudo systemctl status jenkins
You can check if Jenkins is running normally.
Troubleshooting
To check logs:
sudo journalctl -u jenkins.service
To monitor logs in real-time:
sudo journalctl -u jenkins.service -f
Windows Environment
If you have Jenkins set up on a Windows server, there are two ways:
- If Jenkins is registered as a Windows service, you can operate it there.
- You can also operate from the command line with the following commands.
stop
C:\Program Files (x86)\Jenkins>jenkins.exe stop
start
C:\Program Files (x86)\Jenkins>jenkins.exe start
restart
C:\Program Files (x86)\Jenkins>jenkins.exe restart
Operations via Jenkins UI
You can stop or restart by logging into Jenkins as an administrator and accessing URLs.
exit
[🔗 http://<jenkins.server>/exit](http://<jenkins.server>/exit)
safe exit
[🔗 http://<jenkins.server>/safeExit](http://<jenkins.server>/safeExit)
quiet down
[🔗 http://<jenkins.server>/quietDown](http://<jenkins.server>/quietDown)
cancel quiet down
[🔗 http://<jenkins.server>/cancelQuietDown](http://<jenkins.server>/cancelQuietDown)
restart
[🔗 http://<jenkins.server>/restart](http://<jenkins.server>/restart)
safe restart
[🔗 http://<jenkins.server>/safeRestart](http://<jenkins.server>/safeRestart)
Screens During Stop/Start

When you open the URL, a screen like the above will appear. Click Yes to send a request to Jenkins.

If a screen like the above appears, click Retry using Post to send a request to Jenkins.

During shutdown, it will be displayed on the screen like this.

After executing restart, wait on this screen for a while. The screen will reload after the restart is complete.
Remote Operations of Jenkins
Security Warning: The following examples use API tokens. In actual operation, store them in environment variables or use credential files.
RemoteAPI (wget)
To stop using the wget command, use the following.
Note: Specify your username for <user> and the obtained API token for <api-token>.
exit
wget --user=<user> --password=<api-token> --post-data='' http://<jenkins.server>/exit
safe exit
wget --user=<user> --password=<api-token> --post-data='' http://<jenkins.server>/safeExit
quiet down
wget --user=<user> --password=<api-token> --post-data='' http://<jenkins.server>/quietDown
cancel quiet down
wget --user=<user> --password=<api-token> --post-data='' http://<jenkins.server>/cancelQuietDown
restart
wget --user=<user> --password=<api-token> --post-data='' http://<jenkins.server>/restart
safe restart
wget --user=<user> --password=<api-token> --post-data='' http://<jenkins.server>/safeRestart
RemoteAPI (curl)
To stop using the curl command (recommended), use the following.
exit
curl -X POST -u <user>:<api-token> http://<jenkins.server>/exit
safe exit
curl -X POST -u <user>:<api-token> http://<jenkins.server>/safeExit
quiet down
curl -X POST -u <user>:<api-token> http://<jenkins.server>/quietDown
cancel quiet down
curl -X POST -u <user>:<api-token> http://<jenkins.server>/cancelQuietDown
restart
curl -X POST -u <user>:<api-token> http://<jenkins.server>/restart
safe restart
curl -X POST -u <user>:<api-token> http://<jenkins.server>/safeRestart
Jenkins CLI
You can do the same using Jenkins CLI.
Authentication Method 1: Using -auth parameter
java -jar jenkins-cli.jar -s http://<jenkins-server>/ -auth <user>:<api-token> <command>
Authentication Method 2: Using environment variables
export JENKINS_USER_ID=<user>
export JENKINS_API_TOKEN=<api-token>
java -jar jenkins-cli.jar -s http://<jenkins-server>/ <command>
exit
java -jar jenkins-cli.jar -s http://<jenkins-server>/ -auth <user>:<api-token> shutdown
safe exit
java -jar jenkins-cli.jar -s http://<jenkins-server>/ -auth <user>:<api-token> safe-shutdown
quiet down
java -jar jenkins-cli.jar -s http://<jenkins-server>/ -auth <user>:<api-token> quiet-down
cancel quiet down
java -jar jenkins-cli.jar -s http://<jenkins-server>/ -auth <user>:<api-token> cancel-quiet-down
restart
java -jar jenkins-cli.jar -s http://<jenkins-server>/ -auth <user>:<api-token> restart
safe restart
java -jar jenkins-cli.jar -s http://<jenkins-server>/ -auth <user>:<api-token> safe-restart
Summary
Let me summarize the content again.
Jenkins start, stop, and restart methods are classified into the following patterns:
- Operations on Jenkins Environment
- Directly operate Jenkins installed on Linux or Windows.
- On Linux, use systemd (
systemctl).
- Operations via Jenkins UI
- Perform operations by logging into Jenkins.
- Remote Operations of Jenkins
- Operate remotely via API or CLI.
- Use API tokens (passwords are deprecated).
Additionally, there are normal mode and safe mode for stopping and restarting Jenkins, so use them appropriately depending on the situation.
Security Points:
- Do not write passwords directly in commands
- Use API tokens
- Manage tokens with environment variables or credential files
References
- Managing systemd services - Jenkins
- Authenticating scripted clients - Jenkins
- How to Start, Stop or Restart your Instance? - CloudBees
- Jenkins CLI - Jenkins
Recommended Books
[📦 商品リンク: moshimo-book-jenkins-jissen]
[📦 商品リンク: moshimo-book-server-infra]