WAS v8.5 > Reference > Command-line utilities

WASService command

The WASService command line tool enables you create a service for a product Java process on Linux and Windows operating systems.

We can create services for WebSphere Application Server Java processes. Potential services include the following server processes:

When the installation wizard creates a service, the uninstaller program can remove the service. If we use the WASService command to create a service yourself, it is your responsibility to remove the service when it is no longer valid. The uninstaller program does not remove services that you create with the WASService command.

As an alternative to the WASService command, we can use the WASServiceHelper utility, which complements the WASService command and reduces possible configuration errors. For more information, see the documentation about using the WASServiceHelper to create Windows services.

To set up and run this function on a Microsoft Windows operating system, the user must belong to the administrator group and have the following advanced user rights:


Location of the command file

The wasservice.sh command file is located in the app_server_root\bin directory.

The WASService.exe command file is located in the app_server_root\bin directory.


Command syntax


Command syntax for starting an existing service

The command syntax is as follows:


Command syntax for creating a service or updating an existing service

The command syntax is as follows:

wasservice.sh -add service_name
   -serverName server_name
   -profilePath server_profile_directory
   [-wasHome app_server_root]
   [-startArgs additional_start_arguments]
   [-stopArgs additional_stop_arguments]
   [-userid user_id -password password]
        

Note: Specifying wasservice.sh with -userid @myuser causes the startServer.sh to be run by the specified userid (myuser) instead of running startServer.sh as root. Specifying -userid @myuser in this way eliminates the need to change the userid while the JVM is initializing, which requires you to consider a more complicated filesystem setup (Some of the WAS and Java code is running under root). If your profile was installed by a non-root user, invoke wasservice.sh with -userid @myuser. This method is similar to logging in as myuser and interactively starting the server.

WASService.exe -add service_name
   -serverName server_name
   -profilePath server_profile_directory
   [-wasHome app_server_root]
   [-configRoot configuration_repository_directory]
   [-startArgs additional_start_arguments]
   [-stopArgs additional_stop_arguments]
   [-userid user_id -password password]
   [-logFile service_log_file]
   [-logRoot server_log_directory]
   [-restart true | false]
   [-startType automatic | manual | disabled]
      

Although the -logroot parameter is optional, it is advisable to include this optional parameter. In some cases, when we do not specify this optional parameter, you might see an error in the event log that says the application server is attempting to create a service with the -logroot parameter.


Command syntax for deleting a service

The command syntax is as follows:


Command syntax for stopping a running service

The command syntax is as follows:


Command syntax for retrieving service status

The command syntax is as follows:


Required parameters

The following parameters are required with this command:

-profilePath server_profile_directory

Use this option to specify the directory path of the profile that defines the server process.

-serverName server_name

Use this option to identify the server the service controls.


Optional parameters

The following parameters are optional with this command:

-add service_name

Use this option to create a service named service_name or update an existing service. The syntax is the same for both cases.

-configRoot configuration_repository_directory

Use this option to identify the configuration directory of the installation root directory of a WAS product.

-encodeParams service_name

Use this option to force the service to encode the -startArgs and -stopArgs so the arguments cannot be determined by editing the registry. Use the parameter when creating a service with the -add parameter by adding -encodeParams to the command line with no arguments.

Or encode the parameters of an existing service:

    WASService -encodeParams service_name

-logFile service_log_file

Use this option to identify a log file the WASService command uses to record its activity.

-logRoot server_log_directory

Use this option to identify the server log directory for the profile. The WASService command looks for a file named server_name.pid to determine if the server is running.

-remove service_name

Use this option to delete the specified service.

-restart true | false

Specify whether or not the existing service restarts automatically if the service fails. The existing service does not restart automatically if you set the value to false. By default, the restart behavior is set to true, which enables the existing service to restart automatically if it fails.

-start service_name [optional startServer.bat parameters]

Use this option to start the existing service.

-startArgs additional_start_arguments

Use this option to identify additional parameters.

-startType automatic | manual | disabled

Use this option to define the startup type of the new service. An automatic startup type starts automatically when the system starts or when the service is called for the first time. Start a manual service before the operating system can load it and make it available. We cannot start a disabled service before changing the startup type. By default, the value for this parameter is set to automatic.

-status service_name

Use this option to return the current status of the service, which includes whether the service is running or stopped.

-stop service_name [optional stopServer.bat parameters]

Use this option to stop the specified service.

-stopArgs additional_stop_arguments

Use this option to specify additional parameters.

-userid user_id -password password

Use this option to identify a privileged user ID and password the Windows service will run as.

-wasHome app_server_root

Use this option to identify the installation root directory of the product.


Default names for services created by the wizard

The name of the service that is created by the installation wizard is IBM WAS V8.x - DefaultNode.


View the services panel

To view services, open the Control panel and click Administrative Tools > Services. Select a service to view information about it. Right click the service and click Properties. Four tabs provide information and functionality. For example, select the Setup type field on the General tab to change the setup type.

Examples


Create an application server service

This example creates a service called IBM WAS V8.x - name_of_the_application_server_service that starts an application server process:

WASService -add name_of_the_application_server_service
   -servername application_server_name
   -profilePath profile_root
   -wasHome app_server_root
   -logFile WS_startServer.log
   -logRoot profile_root\logs\application_server_name
   -restart true
where

After entering the command, messages that are similar to those in the following example display in the command window:

 Add Service: name_of_the_application_server_service
  Config Root: profile_root\config
  Server Name: application_server_name
  Profile Path: profile_root
  Was Home: app_server_root
  Start Args:
  Restart: 1
IBM WAS V8.x - name_of_the_application_server_service service successfully added.


Update an existing application server service

This example for the Windows operating system updates an existing service called IBM WAS V8.x - Server2 Service with additional stop arguments, the user name and password. The parameters are automatically passed into the script the Windows service uses to shut down the system.

WASService -add "Server2 Service"
   -servername server2
   -profilePath profile_root
   -logRoot profile_root\logs\server2
   -stopArgs "-username user_name  -password password"
   -encodeParams

Start and stop a server process after creating a Windows service

For this Windows operating system example, if you issue the startServer server1 command or the stopServer server1 after creating a Windows service for server1, a message that is similar to the following example displays:

Creating and removing a WebSphere service in Windows can be confusing and error prone. For help in any diagnosing errors, see the information on using WASServiceCmd to create Windows services for WASs.


Related


Automatically restarting server processes
Use the WASServiceHelper utility to create Windows services for application servers


Related information:

Access problems after enabling security


+

Search Tips   |   Advanced Search