Sapcontrol is an os command line tool which gives status and control on various sap services. This is an important tool to manage and monitor the sap system which can be the application server as well as the sap hana environment services. To make the best use of sap control command line syntaxes is to know what functions are available and to keep those that you really need. For example, if you are a sap hana administrator, you will be mainly looking at starting and stopping the sap hana system when it is required but also you will be looking at checking all services status while shutting down or starting up the system.
The following sapcontrol syntax examples are mainly used in a sap hana system environment. Connection to sap hana studio or sap hana cockpit may not be available for various reasons. Here is the most convenient way to checkout all running services while performing operations on the server.
# # -- Useful sapcontrol commands # $> VINSTANCENO=07 $> sapcontrol -nr $VINSTANCENO -function GetVersionInfo 23.12.2020 15:29:40 GetVersionInfo OK Filename, VersionInfo, Time /usr/sap/BAT/HDB07/exe/sapstartsrv, 715, patch 621, changelist 1974931, RKS compatibility level 0, opt (Mar 27 2020, 21:44:00), linuxx86_64, 2020 05 28 10:09:18 # ---------------------- Get all local sap services status $> sapcontrol -nr $VINSTANCENO -function GetProcessList 23.12.2020 15:31:17 GetProcessList OK name, description, dispstatus, textstatus, starttime, elapsedtime, pid hdbdaemon, HDB Daemon, GREEN, Running, 2020 10 08 19:04:08, 1821:27:09, 55085 hdbcompileserver, HDB Compileserver, GREEN, Running, 2020 10 08 19:04:21, 1821:26:56, 55427 hdbdiserver, HDB Deployment Infrastructure Server, GREEN, Running, 2020 10 08 19:04:59, 1821:26:18, 58616 hdbdiserver, HDB Deployment Infrastructure Server-TEX, GREEN, Running, 2020 10 29 07:58:00, 1327:33:17, 4767 hdbdpserver, HDB DPserver-TEX, GREEN, Running, 2020 10 29 07:57:38, 1327:33:39, 3720 hdbdpserver, HDB DPserver-BEX, GREEN, Running, 2020 10 08 19:04:23, 1821:26:54, 55483 hdbindexserver, HDB Indexserver-TEX, GREEN, Running, 2020 10 29 07:57:38, 1327:33:39, 3723 hdbindexserver, HDB Indexserver-BEX, GREEN, Running, 2020 10 08 19:04:23, 1821:26:54, 55489 hdbindexserver, HDB Indexserver-BARINT, GREEN, Running, 2020 10 08 19:04:23, 1821:26:54, 55492 hdbindexserver, HDB Indexserver-FORST, GREEN, Running, 2020 10 08 19:04:23, 1821:26:54, 55495 hdbnameserver, HDB Nameserver, GREEN, Running, 2020 10 08 19:04:09, 1821:27:08, 55104 hdbpreprocessor, HDB Preprocessor, GREEN, Running, 2020 10 08 19:04:21, 1821:26:56, 55430 hdbwebdispatcher, HDB Web Dispatcher, GREEN, Running, 2020 10 08 19:04:59, 1821:26:18, 58622 hdbxscontroller, HDB XS Controller, GREEN, Running, 2020 10 08 19:04:59, 1821:26:18, 58625 hdbxsexecagent, HDB XS Execution Agent, GREEN, Running, 2020 10 08 19:04:59, 1821:26:18, 58628 hdbxsuaaserver, HDB XS UBC Server, GREEN, Running, 2020 10 08 19:04:59, 1821:26:18, 58633 # ---------------------- $> sapcontrol -nr $VINSTANCENO -function GetSystemInstanceList 23.12.2020 15:35:35 GetSystemInstanceList OK hostname, instanceNr, httpPort, httpsPort, startPriority, features, dispstatus linux7, 7, 50713, 50714, 0.3, HDB|HDB_WORKER|HDB_XS_WORKER, GREEN # ---------------------- Get sap instance local host name $> sapcontrol -nr $VINSTANCENO -function ParameterValue SAPLOCALHOST 23.12.2020 15:36:33 ParameterValue OK linux7 # ---------------------- get sap profile complete name $> sapcontrol -nr $VINSTANCENO -function ParameterValue SAPPROFILE 23.12.2020 15:37:35 ParameterValue OK /usr/sap/BAT/SYS/profile/BAT_HDB07_linux7 # ---------------------- Get sap instance Log Files $> sapcontrol -nr $VINSTANCENO -function ListLogFiles 23.12.2020 16:05:24 ListLogFiles OK filename, size, modtime, format linux7/trace/hdbinst_offline_hdbinst_2020-07-21_10.56.14_71836.log, 826482, 2020 07 21 10:57:10, Text linux7/trace/backup.log, 18460106, 2020 12 22 14:48:12, Text linux7/trace/nameserver_linux7.00000.000.trc, 579894, 2020 10 08 19:05:59, Text linux7/trace/nameserver_alert_linux7.trc, 29520188, 2020 12 16 23:04:24, Text . . . . . . # ---------------------- Get sap instance trace Files $> sapcontrol -nr $VINSTANCENO -function GetTraceFile 23.12.2020 16:07:54 GetTraceFile OK lines --------------------------------------------------- trc file: "sapstartsrv.log", trc level: 0, release: "741" --------------------------------------------------- pid 54994 [Thr 140511301904256] Thu Oct 8 19:04:06 2020 HistoryLog_Init: logfile (/usr/sap/BAT/HDB07/linux7/trace/history.glf) already exists, check parameter No halib defined => HA support disabled CCMS agent initialization: WARNING: cannot recognize instance type, checking profile parameter "system/type". CCMS agent initialization for instance type ABAP: return code 0. . . . . . . # ---------------------- Get sap environment variables setting # BAT is the instance name: # ( Note : login as batadm; typing 'env' at the command line will also give the environment variables ) batadm@linux7:/usr/sap/BAT/HDB07> sapcontrol -nr $VINSTANCENO -function GetEnvironment 23.12.2020 16:11:34 GetEnvironment OK lines LD_LIBRARY_PATH=/usr/sap/BAT/HDB07/exe:/usr/sap/BAT/HDB07/exe/krb5/lib/krb5/plugins/preauth:/usr/sap/BAT/HDB07/exe/krb5/lib:/usr/sap/BAT/HDB07/exe:/usr/sap/BAT/HDB07/exe/Python/lib:/usr/sap/BAT/HDB07/exe/filter:/usr/sap/BAT/HDB07/exe/dat_bin_dir:/usr/sap/BAT/HDB07/exe/plugins/afl:/usr/sap/BAT/HDB07/exe/plugins/lcapps:/usr/sap/BAT/HDB07/exe/plugins/repository:/usr/sap/BAT/HDB07/exe/plugins/epmmds:/usr/sap/BAT/SYS/global/hdb/federation:/usr/sap/BAT/SYS/global/hdb/plugins/3rd_party_libs HOSTTYPE=x86_64 PYTHONHOME=/usr/sap/BAT/HDB07/exe/Python LESSCLOSE=lessclose.sh %s %s XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB DIR_EXECUTABLE=/usr/sap/BAT/HDB07/exe LANG=en_US.UTF-8 WINDOWMANAGER=/usr/bin/gnome HOSTNAME=linux7 OLDPWD=/usr/sap/BAT/HDB07 CSHEDIT=emacs TINSTANCE=07 GPG_TTY=/dev/pts/1 . . . . . .