stataid
August 16, 2023 ยท View on GitHub
Obtaining and displaying information about running Stata instances and closing Stata instances in Microsoft Windows.
Table of Contents
1. Syntax
To obtain information about running Stata instances:
stataid list , [exename(_string_) list mata ]
To close a running Stata instance using a Windows process id:
stataid kill, id(_idnumber_)
2. Options
exename(string) Name of Stata executable. stataid tries to determine the name of the executable, but might fail in case the executable has a non standard name.
mata Saves the data in a mata matrix called stataid.
kill(idnumber) Kills process with specific id number.
3. Description
stataid obtains information about all running Stata processes of a Microsoft Windows system. It retrieves the running tasks using shell and tasklist of the command line. The following information are saved:
-
Name of the exe file (image name)
-
Process id
-
The name of the session
-
The number of the session
-
Memory used
-
The status
-
The username
-
CPU time
-
Windowtitle
stataid can close any Stata instance, including the running one. Using the parameter kill, it closes the Stata instance defined by id(). Internally stataid uses the Windows command line command taskkil to kill the Stata instance.
Note, Stata is closed without saving any data!
4. Stored Values
stataid stores the following in r():
Scalars:
r(instances) Number of Stata instances (only with stataid list).
5. Examples
To retrieve a list of all current running Stata instances (2 are running and list the result):
stata stataid list
The output will be:
. stataid list
Obtaining number of Stata instances running under StataSE-64.exe.
2 Stata instance(s) running.
Kill Stata instance with id 13424:
. stataid kill , id(13424)
CPU process id 13424 going to be closed.
6. About
Jan Ditzen (Heriot-Watt University)
Email: j.ditzen@hw.ac.uk
Web: www.jan.ditzen.net
This version: 1.0