How to restart Jenkins manually?

Jenkins

Jenkins Problem Overview


I've just started working with Jenkins and have run into a problem. After installing several plugins it said it needs to be restarted and went into a "shutting down" mode, but never restarts.

How do I do a manual restart?

Jenkins Solutions


Solution 1 - Jenkins

To restart Jenkins manually, you can use either of the following commands (by entering their URL in a browser):

(jenkins_url)/safeRestart - Allows all running jobs to complete. New jobs will remain in the queue to run after the restart is complete.

(jenkins_url)/restart - Forces a restart without waiting for builds to complete.

Solution 2 - Jenkins

If you installed as a rpm or deb, then service jenkins restart will work also.

Solution 3 - Jenkins

On Ubuntu or Debian, when installed through apt-get/dpkg:

$ sudo /etc/init.d/jenkins restart
Usage: /etc/init.d/jenkins {start|stop|status|restart|force-reload}

Solution 4 - Jenkins

The SafeRestart Plugin needs to be mentioned. It is pretty useful (Restart Safely). It adds a link to be able to restart from the main menu:

Enter image description here

Solution 5 - Jenkins

The below commands worked for me in Red Hat Linux and should work for Ubuntu also.

  • To know the status of Jenkins:

      sudo service jenkins status
    
  • To start the Jenkins:

      sudo service jenkins start
    
  • To stop the Jenkins:

      sudo service jenkins stop
    
  • To restart the Jenkins:

      sudo service jenkins restart
    

Demo on command prompt:

[root@varunHome]# sudo service jenkins status
jenkins (pid  7468) is running...

[root@varunHome]# sudo service jenkins stop
Shutting down Jenkins               [  OK  ]

[root@varunHome]# sudo service jenkins start
Starting Jenkins                    [  OK  ]

[root@varunHome]# sudo service jenkins restart
Shutting down Jenkins               [  OK  ]

Starting Jenkins                    [  OK  ]
[root@varunHome]#

The folks who are using windows

Open Console/Command line --> Go to your Jenkins installation directory. Execute the following commands respectively:

To stop:
jenkins.exe stop

To start:
jenkins.exe start

To restart:
jenkins.exe restart

Solution 6 - Jenkins

On Windows, if you installed it as a service, go to Services (StartRun: services.msc), find Jenkins, right click → Restart.

If it does not help (UI is not responding) open the Windows Task Manager → Processes, kill the java.exe process, and restart the service once again.

Solution 7 - Jenkins

You have many options to restart Jenkins manually, but mainly two (URL or command line):

  • Alternative 1: Using the Jenkins installation URL:

    Jenkins_URL/restart. >Example: http://jenkinsserver.com/restart

    This type of restart forces a restart without waiting for builds to complete.

    If you need to wait for the jobs endings you can use:

    Jenkins_URL/safeRestart. >Example: http://jenkinsserver.com/safeRestart

  • Alternative 2: Using the command line, depending on your Jenkins installation.

    • If you're installing using rpm or deb package or you have the Jenkins installation in Red Hat, Ubuntu, or Debian, you can use these commands:

    • sudo service jenkins restart >This restart Jenkins in one step.

    • sudo service jenkins stop and sudo service jenkins start, >This restart Jenkins in two steeps.

    > Note: if you need to check the Jenkins status, you can use this command: sudo service jenkins status

    • If you are using CentOS, you can use this command:

       sudo systemctl restart jenkins
      

    > Note: if you need to check the Jenkins status, you can use this command: sudo systemctl status Jenkins

Solution 8 - Jenkins

This can also be done using the Jenkins CLI:

java -jar jenkins-cli.jar -s http://[jenkins-server]/ restart

The jenkins-cli.jar file along with a full list of commands are available at http://[jenkins-server]/cli.

Solution 9 - Jenkins

If you're running Jenkins on Mac OS X then you can manually stop the service by executing this command:

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

Solution 10 - Jenkins

If you want to just reload the configuration file, one can do

    <jenkins_url>/reload

This is quicker if you have made some small change in the configuration file, like config.xml directly in the file system or made copies of the job through the filesystem (not through the browser).

Solution 11 - Jenkins

It depends on how Jenkins has been started.

  • As a service: sudo service jenkins restart, sudo /etc/init.d/jenkins restart, etc.

  • As a web application in a Tomcat installation: restart your Tomcat, or just restart the application in Tomcat. Go to http://<tomcat-server>:8080/manager/list or after authentication hit http://<tomcat-server>:8080/manager/stop?path=/myapp+ http://<tomcat-server>:8080/manager/start?path=/myapp.

  • Launched with just java -jar: kill it (kill -9 <pid>), and relaunch it.

  • Launched with java -jar, but from a supervisor: supervisorctl restart jenkins

Solution 12 - Jenkins

Use the command line interface:

java -jar jenkins-cli.jar -s http://jenkins.example.com:8080/ -i /root/.ssh/id_rsa safe-restart

Solution 13 - Jenkins

Sometimes there will be some stale Jenkins processes, so ps -ef | grep jenkins kill all of them. Restart as described in previous answers, and it will be clean.

ps -ef | grep jenkins
sudo kill -kill <pid>

Solution 14 - Jenkins

On Windows

Go to the Jenkins installation, open the cmd and run:

  • To stop:

     jenkins.exe stop
    
  • To start:

     jenkins.exe start
    
  • To restart:

     jenkins.exe restart
    

Solution 15 - Jenkins

If you are running Jenkins in FreeBSD(OS):

/usr/local/etc/rc.d/jenkins restart

Solution 16 - Jenkins

If you are able to access it in a web browser, just add /restart, for example, localhost:8080/restart.

If you are running it as a service then log in to your server and execute the command:

sudo service jenkins stop/start

Solution 17 - Jenkins

For Mac

###Stop Jenkins###

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

###Start Jenkins###

sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Solution 18 - Jenkins

For restarting Jenkins manually using the browser:

Enter your www.jenkins-ip/restart (for example, http://localhost:8080/restart) in the browser. Jenkins will restart and load the login page automatically after restart.

Solution 19 - Jenkins

If it is deployed as a war file then restart the application server, for example, Tomcat.

Solution 20 - Jenkins

JenkinURL/restart will do the restart.


/usr/local/etc/rc.d/jenkins restart

Solution 21 - Jenkins

Several people have mentioned the need to restart the servlet container if Jenkins is not running as a standalone. But Tomcat (or what is being used) doesn't need to be restarted. Tomcat can force a restart of the Jenkins context if your Jenkins restart is hung.

But to address another comment, when you put Jenkins in the "shutting down" mode it will not actually shut down. It stops new jobs from executing and place a giant red banner on the system pages so everyone knows that the administrator wants to take it down eventually. There are plugins to trigger a servlet container restart for that context after all builds are completed.

The alternative is to wait till the last running job completes, then manually kick over Jenkins from the container (or via the command line options that others have mentioned for the standalone Jenkins install).

Solution 22 - Jenkins

From the terminal:

sudo service jenkins restart

Or jenkinsurl/restart.

Solution 23 - Jenkins

For CentOS:

sudo systemctl restart jenkins

sudo systemctl status Jenkins

Jenkins will be active and up and running on some PID.

Solution 24 - Jenkins

If it is in a Docker container, you can just restart your container. Let's assume the container name is jenkins, so you can do:

docker restart jenkins

Or

docker stop jenkins
docker start jenkins

Solution 25 - Jenkins

Try the below. It worked for me.

sudo service jenkins status  

It will give you PID of Jenkins. Now do a

kill -15 [PID]

sudo service jenkins start

Solution 26 - Jenkins

If nothing works then find the Jenkins process by

ps aux | grep java

and then kill it:

kill -9 [PID]

sudo service jenkins start

Edit : Look for the java process which is related to jenkins

Solution 27 - Jenkins

Browse http://[jenkins-server-url]/updateCenter/ and just check 'restart jenkins'

Solution 28 - Jenkins

Windows

Run services.msc and restart:

Enter image description here

Solution 29 - Jenkins

If you are running Jenkins as a server on a Windows machine, then open Task Manager and switch to the service tab. Search for Jenkins and restart it.

Solution 30 - Jenkins

If you have no permissions or access to the command line directly, you can do e.g. one of the following:

  1. Create a job with shell/batch step that will trigger a restart from the Jenkins installation folder
  2. Install/update some plugin while checking "restart after installation" (at least this works in old versions)

Both above are hacks, but I actively used them in a very restricted environment where no one wanted me to restart Jenkins, huh.

Solution 31 - Jenkins

jenkins_url/restart is the safest way of doing it.

For service- Service Jenkins restart.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKerry JonesView Question on Stackoverflow
Solution 1 - JenkinsŽeljko FilipinView Answer on Stackoverflow
Solution 2 - JenkinsBen MathewsView Answer on Stackoverflow
Solution 3 - JenkinsTimo TijhofView Answer on Stackoverflow
Solution 4 - JenkinsVitalii ElenhauptView Answer on Stackoverflow
Solution 5 - JenkinsVarunView Answer on Stackoverflow
Solution 6 - JenkinsConstantineView Answer on Stackoverflow
Solution 7 - JenkinsJavier C.View Answer on Stackoverflow
Solution 8 - JenkinsCiaranView Answer on Stackoverflow
Solution 9 - JenkinsJalalView Answer on Stackoverflow
Solution 10 - JenkinsinfocloggedView Answer on Stackoverflow
Solution 11 - JenkinsFrançois SAMINView Answer on Stackoverflow
Solution 12 - JenkinsdomidcView Answer on Stackoverflow
Solution 13 - JenkinssharpView Answer on Stackoverflow
Solution 14 - JenkinsMonis MajeedView Answer on Stackoverflow
Solution 15 - JenkinsEric CopeView Answer on Stackoverflow
Solution 16 - JenkinsRizwan JavidView Answer on Stackoverflow
Solution 17 - JenkinsSazzad Hissain KhanView Answer on Stackoverflow
Solution 18 - JenkinsVaibhav WalkeView Answer on Stackoverflow
Solution 19 - JenkinssharpView Answer on Stackoverflow
Solution 20 - JenkinsSebinView Answer on Stackoverflow
Solution 21 - JenkinsJasonRobinsonView Answer on Stackoverflow
Solution 22 - JenkinsSidharthaView Answer on Stackoverflow
Solution 23 - JenkinsAamir M MemanView Answer on Stackoverflow
Solution 24 - JenkinsYoussouf MaigaView Answer on Stackoverflow
Solution 25 - JenkinsAvinash AgrawalView Answer on Stackoverflow
Solution 26 - JenkinsNeilView Answer on Stackoverflow
Solution 27 - JenkinshoiView Answer on Stackoverflow
Solution 28 - JenkinsTiago MediciView Answer on Stackoverflow
Solution 29 - JenkinsPrem ChoudharyView Answer on Stackoverflow
Solution 30 - JenkinsTEH EMPRAHView Answer on Stackoverflow
Solution 31 - JenkinsBiswajit DasView Answer on Stackoverflow