Starting, stopping, and restarting Jenkins on Windows

Jenkins by default starts running when installed. In this section, the commands to start, stop, restart, and check the status of the Jenkins services are shown:

  1. Open the Services window from Command Prompt using the following command:
        services.msc 
  1. Look for a service named Jenkins.
  2. Right-click on the Jenkins service again and click Properties.
  3. Under the General tab, you can see the Jenkins service name, the path to the executable, the service status, and the start parameters.
  4. Using the Startup type option, you can choose the way Jenkins starts on the Windows machine. You can choose from Automatic, Manual, and Automatic (Delayed Start). Make sure it's always set to Automatic.
  1. In the following service status, there is an option to manually Start, Stop, Pause, and Resume the Jenkins service:

Configuring the Jenkins service startup option

  1. Go to the next tab, which is Log On. Here, we define the username through which Jenkins start.
  2. You can either choose to use the Local System account (not recommended) or you can create a special Jenkins user with special permissions (recommended):

An exclusive account for Jenkins is always preferred. The reason is that Local System account is not under control; it may get deleted or the password may expire depending on the organization's policies, whereas the Jenkins user account can be set with preferred policies and privileges.

Configuring the Jenkins service Log On option

  1. The next tab is Recovery. Here, we can specify the action items in case the Jenkins service fails to start.
  1. Here is an example. At the first failure, there is an attempt to restart Jenkins, at the second failure an attempt is made to restart the computer. And lastly, at subsequent failures, a program is run to debug the issue, or we can run a script that sends the Jenkins failure log through email to the respective Jenkins admin for investigation:

Configuring the Jenkins service Recovery option