Start Free
SonarQube Community Build | Server installation and setup | From ZIP file | Starting / stopping server | Running as a service

Running SonarQube as a service

On this page

This page explains how to install and start SonarQube Community Build as a service in case of a ZIP installation. The operation depends on your operating system.

On Windows

Installing or uninstalling SonarQube as a service

> <sonarqubeHome>\bin\windows-x86-64\SonarService.bat install
> <sonarqubeHome>\bin\windows-x86-64\SonarService.bat uninstall

Starting the service

> <sonarqubeHome>\bin\windows-x86-64\SonarService.bat start

Stopping the service

> <sonarqubeHome>\bin\windows-x86-64\SonarService.bat stop

Checking the service status

To check if the SonarQube service is running:

> <sonarqubeHome>\bin\windows-x86-64\SonarService.bat status

On Linux with systemd

On a Unix system using systemd, you can install SonarQube as a service. You cannot run SonarQube as root in Unix systems. Ideally, you will have created a new account dedicated to the purpose of running SonarQube. Let's suppose:

  • The user used to start the service is sonarqube
  • The group used to start the service is sonarqube
  • The Java Virtual Machine is installed in /opt/java/
  • SonarQube has been unzipped into /opt/sonarqube/

Then create the file /etc/systemd/system/sonarqube.service based on the following:

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=simple
User=sonarqube
Group=sonarqube
PermissionsStartOnly=true
ExecStart=/bin/nohup /opt/java/bin/java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /opt/sonarqube/lib/sonar-application-25.1.0.102122.jar
StandardOutput=journal
LimitNOFILE=131072
LimitNPROC=8192
TimeoutStartSec=5
Restart=always
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

Once your sonarqube.service file is created and properly configured, run:

sudo systemctl enable sonarqube.service
sudo systemctl start sonarqube.service

On Linux with initd

The following has been tested on Ubuntu 20.04 and CentOS 6.2.

You cannot run SonarQube as root in *nix systems. Ideally, you will have created a new account dedicated to the purpose of running SonarQube. Let's suppose the user used to start the service is sonarqube. Then create the file /etc/init.d/sonar based on the following:

#!/bin/sh
#
# rc file for SonarQube
#
# chkconfig: 345 96 10
# description: SonarQube system (www.sonarsource.org)
#
### BEGIN INIT INFO
# Provides: sonar
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SonarQube system (www.sonarsource.org)
# Description: SonarQube system (www.sonarsource.org)
### END INIT INFO
 
su sonarqube -c "/usr/bin/sonar $*"

Register SonarQube at boot time (RedHat, CentOS, 64 bit):

sudo ln -s <sonarqubeHome>/bin/linux-x86-64/sonar.sh /usr/bin/sonar
sudo chmod 755 /etc/init.d/sonar
sudo chkconfig --add sonar

Register SonarQube at boot time (Ubuntu, 64 bit):

sudo ln -s <sonarqubeHome>/bin/linux-x86-64/sonar.sh /usr/bin/sonar
sudo chmod 755 /etc/init.d/sonar
sudo update-rc.d sonar defaults

Once registration is done, run:

sudo service sonar start

Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved.

Creative Commons License