33

I use sonarqube 4.3 and I can't find a script to stop sonar in windowsx86-64.

It's awkward to have StartSonar.batand nothing to stop.

When I use it on in linux-x86-64 I can use ./sonar.sh stop.

I saw that there was a StartNTService.bat and a StoptNTService.bat but i don't want to install sonar as a service.

Michael Courcy
  • 627
  • 2
  • 6
  • 13
  • 2
    My SonarQube didn't show up in the processes nor in services in the Windows Tasts Manager. I just had to kill my Java processes. – Vulpo Feb 26 '16 at 10:28

13 Answers13

17

First try to stop the SonarStart.bat by using Ctrl+c as suggested , and then try to open localhost:9000 ( or whichever port you configured sonar server).

If it is still opening then go to task manager and search for wrapper.exe service and stop the service, if no service or app is found then goto:

Task manager>Details> and stop all java.exe process. 

enter image description here

Note: If you running many java applications, right-click the java.exe and choose goto service, and stop only those java.exe that belongs to AppX deployment.

PDHide
  • 18,113
  • 2
  • 31
  • 46
15

When using StartSonar.bat:

  • if you clicked on it, it opened a new Command window and in this case you just have to close the window to stop SonarQube

  • or you executed the script directly in a Command window, and in this case you just have to hit "Control + C" to stop SonarQube

  • 6
    Ctr+C or closing the window didn't give me the feeling I was properly shutting down sonar. Thanks for the answer. – Michael Courcy May 29 '14 at 15:50
  • 7
    No, sonar is still running on win 7 64 – amdev Oct 21 '15 at 13:04
  • I tried closing the Window, didn't work. Ctrl+C worked like a charm. – Henry Dec 18 '15 at 09:53
  • Ctrl+C is the right way, SonarQube code hooks with ESCAPE code and starts stopping server once you press that. You can confirm this form log on console. Killing process is bad. – SACn Sep 26 '17 at 13:49
  • On Windows Server 2016 I had to press Ctrl+C repeatedly in the Command window before the Java Service Wrapper detected the Ctrl-C. Once detected, this wrapper shuts down SonarCube (I am running version 7.2.1). – MikeOnline Jul 24 '18 at 20:03
  • did both of those. It's still running something. – Urasquirrel Jul 15 '22 at 22:16
11

First find the process id using port number. It will be great if you have git have installed where you can execute few linux commands.

Get the process ID

Once you get the process id, just kill the process. It's that much simple. Execute the below command from the normal cmd window.

enter image description here

Sumit Das
  • 311
  • 3
  • 6
9

If you just run sonarqube for demo purposes via .\StartSonar.bat and this is the only java application you use, you can always do the following command which ends the JRE (sometimes CTRL + C does not always stop the running batch file) - you just need to run it as admin.

StopSonar.bat

@powershell kill -name java
Community
  • 1
  • 1
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
5

Open the windows files managment (CTL+ALT+DEL) and kill the jre process of your sonar server. May be you can't kown which process it is if you have more than one. In my case I kill them all.

Salim Hamidi
  • 20,731
  • 1
  • 26
  • 31
2

From my experience I recommend to stop your SonarQube using the command "ctrl + c" (Don't close the command line window without do this).

If you have closed the StartSonar.bat command line without hitting "ctrl + c", you may see your Sonar still running, in this case you will need to kill manually the Java Processes as @arcuri82 mentioned in the Task Manager .

Roni
  • 369
  • 1
  • 7
  • 22
1

I have the exact same problem (on Windows 7). Even when I close the Command window, still SonarQube is running. A "dirty" workaround is to use Java Visual VM (part of the JDK distribution) to see the pid of the Java processes spawn by SonarQube, and then kill them manually from Windows Task Manager (be sure to click on View first to make the pid value column visible).

arcuri82
  • 885
  • 1
  • 8
  • 17
1

Pressing Ctrl + C repeatedly worked for me.

KKR
  • 79
  • 8
0

Simplest way is :

press ctrl+c on background console which is running for sonar

arjun kumar
  • 467
  • 5
  • 12
0

Don't kill process as this could leave resources opened (not recommended). SonarQube console app is programmed to trap Ctrl-C and terminate safely. This can be verified from its console output manually - after we press break.

Instead send break to process using 3rd party application in a new batch file maybe names StopSonar: SendSignal.exe. Format for this is:

SendSignal <pid> <pid> - send ctrl-break to process <pid> (hex ok)

SACn
  • 1,862
  • 1
  • 14
  • 29
0

In windows. If you start SonarQube using StartNTService.bat

Then open start menu, search Services find SonarQube right click and stop that service. You can change restart policy to manual if you want. Work for me

If you start using StartSonar.bat then press Ctrl + C on it's terminal window

Qamar
  • 4,959
  • 1
  • 30
  • 49
0

Use UninstallNTService.bat to stop and remove the SonarQube

Suresh Babu K
  • 18
  • 1
  • 3
-1

Start or Stop the Instance

Start:

sonar.sh start

Start:

sonar.sh console

Graceful shutdown:

sonar.sh stop

Hard stop:

sonar.sh force-stop

Please read Configure & Operate the Server

D.A.H
  • 858
  • 2
  • 9
  • 19