enhance english doc

This commit is contained in:
beiwei30 committed 2018-10-21 14:30:55 +08:00
1 parent 65fc3bf583
commit 66fb3d3dc1
1 file changed
+19 -22
+19 -22
View File
@@ -1,7 +1,7 @@
Arthas Async Jobs
===
Asynchronous jobs in arthas, using commands related to linux jobs.[linux man jobs](http://man7.org/linux/man-pages/man1/jobs.1p.html)。
Asynchronous jobs in arthas. The idea is borrowed from [linux jobs](http://man7.org/linux/man-pages/man1/jobs.1p.html).
## 1. Use & to run the command in the background
@@ -12,6 +12,8 @@ For example, execute the trace command in the background:
trace Test t &
```
By doing this, the current command is put to the background to run, you can continue to execute other commands in the console.
## 2. List background jobs
If you want to list all background jobs, you can execute the `jobs` command and the results are as follows:
@@ -27,41 +29,38 @@ $ jobs
session : 3648e874-5e69-473f-9eed-7f89660b079b (current)
```
You can see that there is currently a background job executing.
You can see that there is currently a background job executing:
* job id is 10, `*` indicates that this job is created by the current session.
* status is `Stopped`
* execution count is the number of executions, which have been executed 19 times since the start.
* timeout date: After this time, the job will automatically timeout and exit.
* timeout date: timeout timestamp, when the time exceeds this timestamp, the job will be automatically timeout and exit.
## 3. Suspend and Cancel job
## 3. Suspend and cancel job
When the job is executing in the foreground, such as directly calling the command `trace Test t` or calling the background job command `trace Test t &`, the job is transferred to the foreground through the `fg` command. At this point, the console cannot continue to execute the command, but can receive and process the following keyboard events:
When the job is executing in the foreground, for example, directly executing the command `trace Test t`, or executing the background job command `trace Test t &`, then putting the job back to the forground via `fg` command, the console cannot continue to execute other command, but can receive and process the following keyboard events:
* ‘ctrl + z’: Suspend the job, the job status will change to `Stopped`, and the job can be restarted by `bg <job-id>` or `fg <job-id>`
* ‘ctrl + c’: Stop the job
* ‘ctrl + d’: According to linux semantics should be the exit terminal, currently arthas ignore this input.
* ‘ctrl + d’: According to linux semantics this should lead to exit the terminal, right now Arthas has not implemented this yet, therefore simply ignore this keystroke.
## 4. fg/bg, switch the job from the foreground to the background, and vise verse
* When a job is executed in the background or in suspended status (use `ctrl + z` to suspend job), `fg <job-id>` can transfer the job to the foreground to continue to run.
* When a job is in suspended status (use `ctrl + z` to suspend job), `bg <job-id>` can put the job to the background to continue to run.
* A job created by other session can only be put to the foreground to run by using `fg` in the current session.
## 4. fg/bg, Bring a background job to the foreground/Restart a stopped background job
## 5. Redirect the output
* When the job is executed in the background or suspended (`ctrl + z` to suspend job), executing `fg <job-id>` will transfer the corresponding job to the foreground to continue execution.
* When the job is suspended (`ctrl + z` to suspend job), executing `bg <job-id>` will continue the corresponding job in the background.
* A job created by a non-current session can only be executed by the current session fg to the foreground.
## 5. Redirect the job output
The job output can be redirect to the specified file by `>` or `>>`, and can be used together with `&` to implement the asynchronous job of the arthas command. such as:
The job output can be redirect to the specified file by `>` or `>>`, and can be used together with `&`. By doing this, you can achieve running commands asynchronously, for example:
```bash
$ trace Test t >> test.out &
```
The trace command will be executed in the background and the output will be redirect to `~/logs/arthas-cache/test.out`. You can continue to execute other commands in the console.
The trace command will be running in the background and the output will be redirect to `~/logs/arthas-cache/test.out`. You can continue to execute other commands in the console, at the same time, you can also examine the execution result from the output file.
When connecting to a remote arthas server, you may not be able to view the files of the remote machine. Arthas also supports automatic redirection to the local cache file. Examples are as follows:
When connect to a remote Arthas server, you may not be able to view the output file on the remote machine. In this case, Arthas also supports automatically redirecting the output to the local cache file. Examples are as follows:
```bash
$ trace Test t >> &
@@ -69,9 +68,7 @@ job id : 2
cache location : /Users/gehui/logs/arthas-cache/28198/2
```
You can see that does not specify the redirect file after `>>`, arthas will automatically redirect the job output to the `~/logs/arthas-cache`.
In the above example, pid is `28198` and job id is `2`.
If output path is not given, Arthas will automatically redirect the output to the local cache. Job id and cache location will be shown on the console. Cache location is a directory where the output files are put. For one given job, the path of its output file contains PID and job id in order to avoid potential conflict with other jobs. In the above example, pid is `28198` and job id is `2`.
## 6. Stop job
@@ -79,5 +76,5 @@ If you want to stop background job, just `kill <job-id>`.
## 7. Others
* Support up to 8 commands at the same time redirect the output to the log file.
* Do not open too many background asynchronous commands at the same time to avoid affecting the performance of the target JVM.
* Support up to 8 commands at the same time to redirect the output to the log files.
* Do not open too many background jobs at the same time to avoid negative performance effect to the target JVM.