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?
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?
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.
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:
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
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
.
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
Use the command line interface:
java -jar jenkins-cli.jar -s http://jenkins.example.com:8080/ -i /root/.ssh/id_rsa safe-restart
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
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).
For CentOS:
sudo systemctl restart jenkins
sudo systemctl status Jenkins
Jenkins will be active and up and running on some PID.
If you have no permissions or access to the command line directly, you can do e.g. one of the following:
Both above are hacks, but I actively used them in a very restricted environment where no one wanted me to restart Jenkins, huh.