Market LiveNIFTY25,263.8-0.14%SENSEX82,192.3+0.34%Gold 24K ₹12,098.38/g down302.9Silver ₹146.46/g down5.43
InsightforGeeks
Technology

How to Start, Stop, Restart and Check the Status of Jenkins on Linux

Sobin Mathew
12 Apr 2024
2 min read
Share:

Jenkins runs as a background service on Linux. This guide lists the commands to control it and what to check when it does not start. It applies to Ubuntu, Debian, CentOS, Red Hat and Amazon Linux installs from the official packages.

Check the status

sudo systemctl status jenkins

Look for active (running) in green. failed or inactive means the service is down.

Start, stop and restart

sudo systemctl start jenkins
sudo systemctl stop jenkins
sudo systemctl restart jenkins

Use restart after changing the Jenkins configuration or installing a plugin that needs one. Jenkins can take up to a minute to answer after starting.

Start automatically on boot

sudo systemctl enable jenkins
sudo systemctl disable jenkins

Older systems that use SysV init

Systems without systemd use the older service command with the same actions:

sudo service jenkins status
sudo service jenkins start
sudo service jenkins stop
sudo service jenkins restart

Open Jenkins in the browser

By default Jenkins listens on port 8080, so visit http://your-server-ip:8080. Open the port in your firewall or cloud security group if the page does not load. On a first install, read the initial admin password with:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

When it will not start

  • Read the log. sudo journalctl -u jenkins -n 100 --no-pager shows the last 100 lines, and /var/log/jenkins/jenkins.log has more.
  • Java is missing or the wrong version. Run java -version, and install the Java version your Jenkins release requires.
  • Port 8080 is taken. Run sudo lsof -i :8080, stop the other program or change the Jenkins port.
  • Permissions. The jenkins user must own /var/lib/jenkins. Fix it with sudo chown -R jenkins:jenkins /var/lib/jenkins.
  • Not enough memory. Small servers can run out of RAM. Check with free -h and consider adding swap.

Restart safely from the web UI

If Jenkins is running, you can also open /safeRestart in the browser. It waits for running builds to finish before restarting, which is safer than restarting the service in the middle of a build.

Tags:#jenkins#ubuntu#server#ci/cd#git
Found this helpful? Share it with friends & colleagues
Share:
Sobin Mathew Verified Editorial Staff

Covering financial markets, commodity rates, and practical technology insights for India. Researched and fact-checked in accordance with our Editorial Policy.

Published on 12 April 2024General Information · Disclaimer

Recommended based on your reading interest

More in Technology