You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
arthas/en/_sources/batch-support.md.txt

46 lines
1.3 KiB
Plaintext

6 years ago
Batch Processing
================
6 years ago
With the help of Batch Processing, you can run multiple commands in batch and get the final result at the end.
6 years ago
### Usage
6 years ago
#### Step 1: Create the script
6 years ago
6 years ago
Create a `test.as` script suffixed with `as`. Here `as` is suggested for the suffix of the filename, but in fact any suffix is acceptable.
6 years ago
6 years ago
```bash
6 years ago
➜ arthas git:(develop) cat /var/tmp/test.as
help
5 years ago
dashboard -n 1
6 years ago
session
thread
sc -d org.apache.commons.lang.StringUtils
```
6 years ago
Note:
* Each command takes one line.
5 years ago
* Batch mode execution times (via `-n`) must be explicitly specified for `dashboard`, otherwise batch script cannot terminate.
6 years ago
* Commands such as `watch`/`tt`/`trace`/`monitor`/`stack` should include `-n` option to ensure the script can be able to quit.
* Also consider to use `async` (for example: `watch c.t.X test returnObj > &`) to put commands run at background and get the output from the log file, see more from [asynchronous job](async.md)
6 years ago
6 years ago
#### Step 2: Run the script
6 years ago
5 years ago
Use `-f` to specify the script file. By default the result will be output to the standard output, but you can redirect the output to the file like this:
6 years ago
6 years ago
```bash
5 years ago
./as.sh -f /var/tmp/test.as 56328 > test.out
```
Use `-c` also can specify the commands, like this:
```bash
./as.sh -c 'sysprop; thread' 56328 > test.out
6 years ago
```
5 years ago
#### Step 3: Check the output
6 years ago
6 years ago
```bash
6 years ago
cat test.out
```