• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# watch
2
3## Command Function<a name="section20643141481314"></a>
4
5This command is used to periodically run the specified command and display its execution result.
6
7## Syntax<a name="section1075441721316"></a>
8
9-   watch
10-   watch \[_-c/-n/-t/--count/--interval/-no-title/--over_\] \[_command_\]
11
12## Parameters<a name="section1472810220135"></a>
13
14**Table  1**  Parameter description
15
16<a name="table966mcpsimp"></a>
17<table><thead align="left"><tr id="row973mcpsimp"><th class="cellrowborder" valign="top" width="19.801980198019802%" id="mcps1.2.5.1.1"><p id="p975mcpsimp"><a name="p975mcpsimp"></a><a name="p975mcpsimp"></a>Parameter</p>
18</th>
19<th class="cellrowborder" valign="top" width="29.222922292229224%" id="mcps1.2.5.1.2"><p id="p977mcpsimp"><a name="p977mcpsimp"></a><a name="p977mcpsimp"></a>Description</p>
20</th>
21<th class="cellrowborder" valign="top" width="22.26222622262226%" id="mcps1.2.5.1.3"><p id="p979mcpsimp"><a name="p979mcpsimp"></a><a name="p979mcpsimp"></a>Default Value</p>
22</th>
23<th class="cellrowborder" valign="top" width="28.712871287128717%" id="mcps1.2.5.1.4"><p id="p981mcpsimp"><a name="p981mcpsimp"></a><a name="p981mcpsimp"></a>Value Range</p>
24</th>
25</tr>
26</thead>
27<tbody><tr id="row982mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p984mcpsimp"><a name="p984mcpsimp"></a><a name="p984mcpsimp"></a>-c / --count</p>
28</td>
29<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p986mcpsimp"><a name="p986mcpsimp"></a><a name="p986mcpsimp"></a>Specifies the number of times that the specified command is executed.</p>
30</td>
31<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p988mcpsimp"><a name="p988mcpsimp"></a><a name="p988mcpsimp"></a>0xFFFFFF</p>
32</td>
33<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p990mcpsimp"><a name="p990mcpsimp"></a><a name="p990mcpsimp"></a>(0, 0xFFFFFF]</p>
34</td>
35</tr>
36<tr id="row991mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p993mcpsimp"><a name="p993mcpsimp"></a><a name="p993mcpsimp"></a>-n / --interval</p>
37</td>
38<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p995mcpsimp"><a name="p995mcpsimp"></a><a name="p995mcpsimp"></a>Specifies the interval (in seconds) for periodically running the specified command.</p>
39</td>
40<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p997mcpsimp"><a name="p997mcpsimp"></a><a name="p997mcpsimp"></a>1s</p>
41</td>
42<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p999mcpsimp"><a name="p999mcpsimp"></a><a name="p999mcpsimp"></a>(0, 0xFFFFFF]</p>
43</td>
44</tr>
45<tr id="row1000mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p1002mcpsimp"><a name="p1002mcpsimp"></a><a name="p1002mcpsimp"></a>-t / -no-title</p>
46</td>
47<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p1004mcpsimp"><a name="p1004mcpsimp"></a><a name="p1004mcpsimp"></a>Disables time display on the top.</p>
48</td>
49<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p1006mcpsimp"><a name="p1006mcpsimp"></a><a name="p1006mcpsimp"></a>N/A</p>
50</td>
51<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p1008mcpsimp"><a name="p1008mcpsimp"></a><a name="p1008mcpsimp"></a>N/A</p>
52</td>
53</tr>
54<tr id="row1009mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p1011mcpsimp"><a name="p1011mcpsimp"></a><a name="p1011mcpsimp"></a>command</p>
55</td>
56<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p1013mcpsimp"><a name="p1013mcpsimp"></a><a name="p1013mcpsimp"></a>Specifies the command to be monitored.</p>
57</td>
58<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p1015mcpsimp"><a name="p1015mcpsimp"></a><a name="p1015mcpsimp"></a>N/A</p>
59</td>
60<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p1017mcpsimp"><a name="p1017mcpsimp"></a><a name="p1017mcpsimp"></a>N/A</p>
61</td>
62</tr>
63<tr id="row1018mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p1020mcpsimp"><a name="p1020mcpsimp"></a><a name="p1020mcpsimp"></a>--over</p>
64</td>
65<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p1022mcpsimp"><a name="p1022mcpsimp"></a><a name="p1022mcpsimp"></a>Stops the current command monitoring.</p>
66</td>
67<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p1024mcpsimp"><a name="p1024mcpsimp"></a><a name="p1024mcpsimp"></a>N/A</p>
68</td>
69<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p1026mcpsimp"><a name="p1026mcpsimp"></a><a name="p1026mcpsimp"></a>N/A</p>
70</td>
71</tr>
72</tbody>
73</table>
74
75## Usage<a name="section186772414131"></a>
76
77You can run the  **watch --over**  command to stop monitoring of the specified command.
78
79## Example<a name="section4764192791314"></a>
80
81Run  **watch -n 2 -c 6 task**.
82
83## Output<a name="section5791253155517"></a>
84
85Example: The  **task**  command is executed six times at an interval of 2 seconds.
86
87```
88OHOS # watch  -n 2 -c 6 task
89Thu Jan  1 23:57:13 1970
90OHOS #
91  allCpu(%):    3.55 sys,  196.45 idle
92  PID  PPID PGID       UID  Status VirtualMem ShareMem PhysicalMem CPUUSE10s  PName
93    1    -1    1         0 Pending   0x33b000  0xbb000     0x4dc8b      0.0   init
94    2    -1    2         0 Running  0x19524f2        0   0x19524f2      1.14  KProcess
95    3     1    3         7 Pending   0x730000 0x1a2000    0x1d34f6      0.0   foundation
96    4     1    4         8 Pending   0x35e000  0xb8000     0x56777      0.0   bundle_daemon
97    5     1    5         1 Pending   0xdfa000 0x2e7000    0x1487ce      0.0   appspawn
98    6     1    6         0 Pending   0x688000 0x137000    0x11c518      0.0   media_server
99    7     1    7         0 Pending   0x9d2000 0x103000     0xa1ddf      0.95  wms_server
100    8     1    1      1000 Running   0x2bf000  0x8f000     0x2a8c6      0.0   shell
101   11     1   11         0 Pending   0x4d4000 0x112000     0xe0ad7      0.0   deviceauth_service
102   12     1   12         0 Pending   0x34f000  0xbd000     0x519ee      0.0   sensor_service
103   13     1   13         2 Pending   0x34e000  0xb3000     0x523d9      0.0   ai_server
104   14     1   14         0 Pending   0x61f000 0x13b000    0x16841c      0.51  softbus_server
105  TID  PID Affi CPU       Status StackSize WaterLine CPUUSE10s    MEMUSE  TaskName
106   23    1  0x3  -1      Pending    0x3000     0xe44      0.0           0  init
107    1    2  0x1  -1      Pending    0x4000     0x2c4      0.64          0  Swt_Task
108    2    2  0x3  -1      Pending    0x4000     0x204      0.0           0  system_wq
109    3    2  0x2  -1      Pending    0x4000     0x514      0.40          0  Swt_Task
110    4    2  0x3  -1      Pending    0x1000     0x36c      0.0           0  ResourcesTask
111    7    2  0x3  -1      Pending    0x4e20     0xa5c      0.0           0  PlatformWorkerThread
112    8    2  0x3  -1      Pending    0x4e20     0xa6c      0.0           0  PlatformWorkerThread
113    9    2  0x3  -1      Pending    0x4e20     0xa5c      0.0           0  PlatformWorkerThread
114   10    2  0x3  -1     PendTime    0x4000     0x3e4      0.5           0  hi_vdec_thread
115   11    2  0x3  -1      Pending    0x3000     0x4cc      0.0           0  bcache_async_task
116   12    2  0x3  -1      Pending    0x2710     0x224      0.0           0  LiteOS usb pnp notify handle kt
117   13    2  0x3  -1      Pending    0x4000     0x204      0.0           0  vibrator_queue
118   14    2  0x3  -1      Pending    0x3000     0x37c      0.0           0  bcache_async_task
119   15    2  0x3  -1      Pending   0x20000     0x3e4      0.0           0  eth_irq_Task
120   16    2  0x3  -1     PendTime    0x2000     0x3a4      0.0           0  MessageDispatcher
121   17    2  0x3   0      Running    0x3000     0x73c      0.0           0  shellcmd_watch
122   18    2  0x3  -1      Pending    0x2710     0x3ac      0.0           0  GPIO_IRQ_TSK_0_4
123```
124
125