Start/Stop and Restart Jenkins service on Windows
Asked Answered
C

10

121

I have downloaded "jenkins-1.501.zip" from http://jenkins-ci.org/content/thank-you-downloading-windows-installer .

I have extracted zip file and installed Jenkins on Windows 7 successfully. Jenkins runs at http://localhost:8080/ well. I want to stop Jenkins service from console. How can I do that? What's the way to start and restart through console/command line?

Chingchinghai answered 14/2, 2013 at 6:51 Comment(1)
On Windows, if you open up Services (from the start menu search) or navigate to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools and then open Services > Scroll down to find Jenkins in the list and you may start/stop it via the UI dialogue box. Or as the list of answers suggest, the command line is a perfectly nice way to do it too.Pogue
P
232

Open Console/Command line --> Go to your Jenkins installation directory (very likely cd "C:\Program Files\Jenkins\"). Execute the following commands respectively:

to stop:
.\jenkins.exe stop

to start:
.\jenkins.exe start

to restart:
.\jenkins.exe restart

Phylys answered 14/2, 2013 at 6:58 Comment(6)
@kapep: What about start and stop in macFerde
How to know the jenkins status?Phylys
@Cryptor, check this post to safely shut down jenkins , it may help.Rudich
I don't know where my Jenkins installation directory is :(Bellbella
Jenkins installation directory is in 'Program Files' or 'Program Files(x86)'Taster
Yeah would most likely be C:\Program Files\JenkinsPogue
S
55

To stop Jenkins Please avoid shutting down the Java process or the Windows service. These are not usual commands. Use those only if your Jenkins is causing problems.

Use Jenkins' way to stop that protects from data loss.

http://[jenkins-server]/[command]

where [command] can be any one of the following

  • exit
  • restart
  • reload

Example: if my local PC is running Jenkins at port 8080, it will be

http://localhost:8080/exit
Shayshaya answered 31/1, 2017 at 20:35 Comment(0)
A
21

So by default you can open CMD and write

java -jar jenkins.war

But if your port 8080 is already is in use,so you have to change the Jenkins port number, so for that open Jenkins folder in Program File and open Jenkins.XML file and change the port number such as 8088

Now Open CMD and write

java -jar jenkins.war --httpPort=8088
Adar answered 22/3, 2018 at 9:50 Comment(0)
S
14

To start Jenkins from command line

  1. Open command prompt
  2. Go to the directory where your war file is placed and run the following command:

    java -jar jenkins.war

To stop

Ctrl + C

Saltpeter answered 4/1, 2017 at 6:49 Comment(4)
Sure enough, this appears to work for me on Windows 7.Tankard
This worked for me, and is also what their documentation recommends: wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+JenkinsAldehyde
using this we can not close the terminal ,coz the jenkins stops on closing the terminal any solution ?Ginseng
when using this process ,all my previous project on jenkins lost and it runs through terminal only.Decapod
L
7

To Start Jenkins through Command Line

  1. Run CMD with admin

  2. You can run following commands

    "net start servicename" to start

    "net restart servicename" to restart

    "net stop servicename" to stop service

for more reference https://www.windows-commandline.com/start-stop-service-command-line/

Leeth answered 21/7, 2020 at 7:57 Comment(1)
This is what I was looking for, but there is no restart. You must do stop followed by start.Cordovan
T
6
       jenkins.exe stop
       jenkins.exe start
       jenkins.exe restart

These commands will work from cmd only if you run CMD with admin permissions

Troche answered 19/7, 2018 at 6:0 Comment(1)
To run cmd in admin mode 1. Open task manager 2. File - New Task 3. Select check box "Create task with admin previleges"Troche
H
2

Small hints for routine work.

Create a bat file, name it and use for exact run/stop/restart Jenkins service

#!/bin/bash
# go to Jenkins folder
cd C:\Program Files (x86)\Jenkins

#to stop:
jenkins.exe stop

#to start:
#jenkins.exe start

#to restart:
#jenkins.exe restart
Horbal answered 27/12, 2019 at 12:12 Comment(1)
This is definitely not a batch file for Windows.Ridotto
C
2

Step 01: You need to add jenkins for environment variables, Then you can use jenkins commands

Step 02: Go to "C:\Program Files (x86)\Jenkins" with admin prompt

Step 03: Choose your option: jenkins.exe stop / jenkins.exe start / jenkins.exe restart

Coz answered 17/5, 2020 at 4:8 Comment(2)
I don't find Jenkins in either of the ProgramFiles foldersCrouse
maybe, you haven't installed it properly.Coz
G
0

Go to the url and paste http://localhost:'portNo'>/exit and enter

Grater answered 11/7, 2022 at 15:53 Comment(1)
If the URL works, that would mean the process is already running, wouldn't it? OP wanted to see how to start/stop it.Pogue
L
0

To run/stop/restart Jenkins in Windows, you can make a bat file with .bat extension

@echo off
rem Go to Jenkins folder
cd "C:\Program Files\Jenkins"

rem To stop Jenkins
jenkins.exe stop

rem To start Jenkins
rem jenkins.exe start

rem To restart Jenkins
rem jenkins.exe restart

rem is for commenting line in windows. Remove rem to execute the particular line.

Run the .bat file as ./your_file_name.bat

Inspired By: Roman Denisenko (https://mcmap.net/q/55132/-start-stop-and-restart-jenkins-service-on-windows)

Leftward answered 4/1 at 4:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.