runs a script for monitoring GlassFish Server events


run-script [--help] [--upload={true|false}] 
[--timeout timeout] [--target target] script-file-name 


The run-script subcommand runs a script for monitoring GlassFish Server events. To stop the script, type Ctrl-C.

This subcommand is supported in remote mode only.



Displays the help text for the subcommand.


Specifies whether the subcommand uploads the file to the DAS. In most situations, this option can be omitted.

Valid values are as follows:


The subcommand does not upload the file and attempts to access the file through the specified file name. If the DAS cannot access the file, the subcommand fails.

For example, the DAS might be running as a different user than the administration user and does not have read access to the file. In this situation, the subcommand fails if the --upload option is false.


The subcommand uploads the file to the DAS over the network connection.

The default value depends on whether the DAS is on the host where the subcommand is run or is on a remote host.

  • If the DAS is on the host where the subcommand is run, the default is false.

  • If the DAS is on a remote host, the default is true.


Specifies the time in seconds to run the script before stopping it automatically. The default is 0 (zero), which means the script is never stopped automatically.


Specifies the target on which you are running the script. Valid values are:


Runs the script on the domain administration server, also called the default server instance, which is named server. This is the default value.


Runs the script on every running server instance in the cluster.


Runs the script on a particular standalone sever instance.



The name, including the absolute or relative path, of the file that contains the script to run. A relative path is relative to the directory from which the run-script subcommand is run.


Example 1   Running a Script for Monitoring GlassFish Server Events

This example runs the script /tools/mon/modulestarted.js for ten minutes (600 seconds).

asadmin> run-script --timeout 600 /tools/mon/modulestarted.js
Example 2   Counting the Number of Started and Stopped Web Modules

This example is a script that counts the number of standalone web modules and web modules in an enterprise archive (EAR) file that are started and the number of web modules that are stopped.

var nModuleStarted=0;
var nModuleStopped=0;

function webModuleStarted(appName, hostName) {
    nModuleStarted = nModuleStarted + 1;
    client.print( '\n js> web-module started event called on ' + 
                  'virtual_server_id =  ' + hostName + ', 
                  for application = ' + appName + ' 
                  and count = ' + nModuleStarted);

function webModuleStopped(appName, hostName) {
    nModuleStopped = nModuleStopped + 1;
    client.print( '\n js> web-module stopped event called on ' + 
                  'virtual_server_id= ' + hostName + ', 
                  for application = ' + appName + ' 
                  and count = ' + nModuleStopped);

params = java.lang.reflect.Array.newInstance(java.lang.String, 2);

    'glassfish:web:web-module:webModuleStartedEvent', params, 'webModuleStarted');
    'glassfish:web:web-module:webModuleStartedEvent', params, 'webModuleStopped');

Exit Status


command executed successfully


error in executing the command

See Also