Running as a service

How to install and start SonarQube Server 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

By default, the service will use the Java executable available on the Windows PATH. This setting can be changed by setting the environmental variable SONAR_JAVA_PATH. See more in Advanced setup.

Stopping the service

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

This command does a graceful shutdown where no new analysis report processing can start, but the tasks in progress are allowed to finish. The time a stop will take depends on the processing time of the tasks in progress. You’ll need to kill all SonarQube Server processes manually to force a 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:

  • Because the sonar-application jar name ends with the version of SonarQube, you will need to adjust the ExecStart command accordingly on install and at each upgrade.

  • All SonarQube directories should be owned by the sonarqube user.

  • If you have multiple Java versions, you will need to modify the java path in the ExecStart command. This also means SONAR_JAVA_PATH will not work with SonarQube as a service.

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

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:

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

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

Once registration is done, run:

Was this helpful?