*Note:
The following instructions are applicable to SOS 2010 and later. Earlier versions of SOS require slightly different command lines. See: http://www.sosoft.com/fod/doc430-startingdbasservice.pdf
Overview
The primary reason to configure the SOS SQL Anywhere database to run as a service is that it will continue to run even if nobody is logged into the server computer. Assuming that you set the service to run automatically, it will start as soon as the server boots up. When a service starts, it uses a special system account called LocalSystem (or use another account you specify). The service is not tied to the user ID of the person starting it, and therefore is not stopped when that person logs off.
To add a new service
- On the computer that runs the SOS database, open a command prompt.
- NOTE: This must be an “administrator mode” command window, so in Server 2008, Vista, and other recent versions of Windows, be sure to right-click the Command Prompt icon and select “Run as Administrator”. In previous versions, it will be enough to log into Windows using an account that has administrator privileges.
- Change to the C:\SOS\SA\Bin32 directory (that is, the SA\Bin32 folder within the folder containing your SOS program files, assuming a default installation on the C: drive).
- Execute the Service Creation Utility using the -w option. For example, to create a database server service called “mysos”, which starts the specified engine with the specified parameters type the following command, all on one line. The options below will set the service to run under the system account, as a network service, to start automatically, to display the database icon in the system tray, and to be named “mysos”. It will appear in the Windows Services Manager as “SQL Anywhere – mysos”. If you are running the database in 64-bit Windows, using the 64-bit option is recommended, but either version of the engine will work. The 64-bit engine often provides better performance, especially for larger databases. Note that the -i option to display the icon in the system tray won’t work on Vista, 7, or Server 2008 and later, so omit that option if using one of those. Service configuration commands are case sensitive. Type your options exactly as shown (eg: “automatic” will fail but “Automatic” will work).
32-bit Windows:
dbsvc -as -t network -s Automatic -i -w mysos c:\sos\sa\bin32\dbsrv11.exe @c:\sos\server.prm c:\sos\data\sosdata.db
64-bit Windows:
dbsvc -as -t network -s Automatic -i -w mysos c:\sos\sa\bin64\dbsrv11.exe @c:\sos\server.prm c:\sos\data\sosdata.db - After executing the command, you will find a new Windows service listed in Windows’ Administrative Tools > Services applet: SQL Anywhere – mysos. You can adjust the properties for the service just as you would for any other service.
Notes on adding a service:
- Service names must be unique within the first eight characters.
- If you choose to start a service automatically, it starts whenever the computer starts Windows.
- Choose the account under which the service will run: the special LocalSystem account or another user ID.
- If you want the service to be accessible from the Windows desktop, check Allow Service to Interact with Desktop. If this option is cleared, no icon or window appears on the desktop or use the -i option when creating the service.
Removing a service
Removing a service removes the server name from the list of services. Removing a service does not remove any software from your hard disk. If you wish to re-install a service you previously removed, you need to re-type the options.
To remove a service (Command line)
- Open an administrator command prompt. (See NOTE under item 1 in the first section of this document.)
- Execute the Service Creation utility using the -d option. For example, to delete the service called “mysos”, without prompting for confirmation, type the following command:
dbsvc -y -d mysos
Notes on removing a service:
In some cases “deleting” a service just marks it for actual removal when you next reboot the system. If you want to delete a service in order to add a new one with the same name, you will have to reboot after doing the deletion, then add the new service when the system has restarted. If you use a different name for the new service, you can disable the old one using the Windows services applet, then delete it as described above so that it will be removed the next time you reboot. You can then add the new service and start it, as long as you are careful to use a different name.
Detailed Reference for the DBSVC Utility
(see also page 820 in the SQL Anywhere Database Administration manual)
Managing services using the dbsvc command-line utility
Syntax dbsvc [ options ] <svc>
dbsvc [-q] [-y] -d <svc>
dbsvc [-q] -g <svc>
dbsvc [-q] -l
dbsvc [-q] [-y] <creation options> -w <svc> <details>
Option | Description |
-a | Account name to use (used with -p) |
-as | Use local system account |
-d <service name> | Delete a service |
-i | Allow service to interact with the desktop. Displays an icon that you can double-click to display the database server messages window. |
-g <service name> | Get details of a service |
-l | List all SQL Anywhere services |
-p | Password for account (used with -a) |
-q | Do not print banner |
-rg dependency… | Specify group dependencies when creating a service |
-rs dependency… | Specify service dependencies when creating a service |
-s startup | Startup option (default is manual). You must specify Automatic, Manual, or Disabled. |
-sd <description> | Use this option to provide a description of the service. The description appears in the Windows Service Manager. |
-t <type> | Type of service, eg: Network |
-u <service name> | Starts the service named service_name |
-w <executable parameters> | Creates a new service, or overwrites one if one of the same name exists. If you supply -y, the existing service is overwritten without confirmation. |
-x <service name> | Stops the service named service_name |
-y | Delete or overwrite service without confirmation |
A service runs a database server or other application with a set of options. This utility provides a comprehensive way of managing Adaptive Server Anywhere services on Windows. The Service Creation utility provides the same functionality as the Service Creation wizard in Sybase Central.
You must be a member of the Administrators group on the local machine to use the Service Creation utility.
Exit codes are 0 (success) or non-zero (failure).
This utility accepts @filename parameters.
Examples
(all executed from the c:\sos\sa\win32 command prompt, even if creating a 64-bit service)
Create a personal (not networked) database service called mypersonaldb, which starts the specified standalone engine with the specified parameters. The engine runs as the LocalSystem user:
32-bit:
dbsvc -as -w mypersonaldb c:\sos\sa\bin32\dbeng11.exe @c:\sos\server.prm c:\sos\data\sosdata.db
64-bit:
dbsvc -as -w mypersonaldb c:\sos\sa\bin64\dbeng11.exe @c:\sos\server.prm c:\sos\data\sosdata.db
Create a network database service called mynetdb. The server runs under the local account, and starts automatically when the machine is booted (all on one line):
32-bit:
dbsvc -as -s Automatic -t Network -w mynetdb c:\sos\sa\bin32\dbsrv11.exe @c:\sos\server.prm c:\sos\data\sosdata.db
64-bit:
dbsvc -as -s Automatic -t Network -w mynetdb c:\sos\sa\bin32\dbsrv11.exe @c:\sos\server.prm c:\sos\data\sosdata.db
List all details about service myserv:
dbsvc -g myserv
Delete the service called myserv, without prompting for confirmation:
dbsvc -y -d myserv