When you submit a SQL, Spark, or MapReduce job in MaxCompute, the system converts it into a MaxCompute instance. Each instance has a unique, permanently valid instance ID. Use the commands in this topic to list instances, check their status, stop a running job, and retrieve job details and logs.
Prerequisites
Before you begin, ensure that you have:
Read or write permissions on instances (varies by operation — see the table below)
Access to one of these platforms:
Operations overview
| Operation | Command | Required permission |
|---|---|---|
| List instances | show instances / ls instances | Read permission on instances, or LIST permission on project objects |
| Query instance status | status | Read permission on instances |
| View running instances | top instance | Read permission on instances, or LIST permission on project objects |
| Stop an instance | kill | Write permission on instances |
| Get job details | desc instance | Read permission on instances |
| Get job logs | wait |
List instances
Lists instances submitted by you or all users in a project, with options to filter by date range, project, and count.
Syntax
show p|proc|processlist|instances [from <startdate>] [to <enddate>] [-p <project_name>] [-limit <number> | <number>] [-all];
ls|list instances [from <startdate>] [to <enddate>] [-p <project_name>] [-limit <number> | <number>] [-all];These statements are equivalent: show p, show proc, show processlist, show instances, ls instances, and list instances.
Parameters
| Parameter | Required | Description |
|---|---|---|
startdate | No | Start of the date range (inclusive). Format: yyyy-mm-dd. Must be earlier than enddate. Defaults to the current day. |
enddate | No | End of the date range (exclusive — instances submitted on this day are not included). Format: yyyy-mm-dd. Defaults to the current day. |
-p project_name | No | The project to query. You must have permission to view instances in that project. Defaults to the current project. |
-limit number | No | Number of most recent instances to return. -limit <number> and <number> are equivalent. |
-all | No | Return instances from all users in the project. Without this flag, only your own instances are returned. |
Default behavior: Without -limit, up to 50 instances are returned.
Output fields
| Field | Description |
|---|---|
| StartTime | The time the instance was submitted (accurate to seconds). |
| RunTime | The execution duration (in seconds). |
| Status | The current instance state. |
| InstanceID | The unique instance ID. Always populated. |
| Owner | The Alibaba Cloud account that submitted the instance. |
| Query | The SQL statement associated with the instance. Blank for non-SQL instances (such as some internal system jobs). |
Examples
List all instances you submitted today:
show p;Sample output:
StartTime RunTime Status InstanceID Owner Query
2021-09-14 11:43:04 0s Success 20210914**************3rw2 ALIYUN$****@test.aliyunid.com
2021-09-14 11:43:05 1s Success 20210914**************5t32 ALIYUN$****@test.aliyunid.com select date_sub(datetime '2005-03-01 00:00:00', 1);
2021-09-14 11:58:13 0s Success 20210914**************5pr2 ALIYUN$****@test.aliyunid.com
2021-09-14 11:58:15 1s Success 20210914**************5qgr ALIYUN$****@test.aliyunid.com select date_sub(date '2005-02-28', -1);
2021-09-14 12:02:15 1s Success 20210914**************h8o7 ALIYUN$****@test.aliyunid.com select date_sub('2008-03-01 00:00:00', 2);
2021-09-14 12:02:15 0s Success 20210914**************5t32 ALIYUN$****@test.aliyunid.com
2021-09-14 12:02:31 0s Success 20210914**************5pr2 ALIYUN$****@test.aliyunid.com
2021-09-14 12:02:32 0s Success 20210914**************euq2 ALIYUN$****@test.aliyunid.com select date_sub('2005-03-01 00:00:00', 2);
2021-09-14 13:35:42 0s Success 20210914**************1ms2 ALIYUN$****@test.aliyunid.com
2021-09-14 13:35:43 0s Success 20210914**************j8o7 ALIYUN$****@test.aliyunid.com select date_sub(getdate(),1);
2021-09-14 13:40:40 1s Success 20210914**************h3wz ALIYUN$****@test.aliyunid.com select date_sub(getdate(),0);
2021-09-14 13:40:40 0s Success 20210914**************9nm7 ALIYUN$****@test.aliyunid.com
12 instancesList your instances from a specific date range, limited to 10 results:
show instances from 2021-09-14 to 2021-09-15 -limit 10;Sample output:
StartTime RunTime Status InstanceID Owner Query
2021-09-14 11:58:13 0s Success 20210914**************5pr2 ALIYUN$****@test.aliyunid.com
2021-09-14 11:58:15 1s Success 20210914**************5qgr ALIYUN$****@test.aliyunid.com select date_sub(date '2005-02-28', -1);
2021-09-14 12:02:15 1s Success 20210914**************h8o7 ALIYUN$****@test.aliyunid.com select date_sub('2008-03-01 00:00:00', 2);
2021-09-14 12:02:15 0s Success 20210914**************5t32 ALIYUN$****@test.aliyunid.com
2021-09-14 12:02:31 0s Success 20210914**************5pr2 ALIYUN$****@test.aliyunid.com
2021-09-14 12:02:32 0s Success 20210914**************euq2 ALIYUN$****@test.aliyunid.com select date_sub('2005-03-01 00:00:00', 2);
2021-09-14 13:35:42 0s Success 20210914**************1ms2 ALIYUN$****@test.aliyunid.com
2021-09-14 13:35:43 0s Success 20210914**************j8o7 ALIYUN$****@test.aliyunid.com select date_sub(getdate(),1);
2021-09-14 13:40:40 1s Success 20210914**************h3wz ALIYUN$****@test.aliyunid.com select date_sub(getdate(),0);
2021-09-14 13:40:40 0s Success 20210914**************9nm7 ALIYUN$****@test.aliyunid.com
10 instancesList instances from all users in another project, filtered by date range, limited to 10 results:
ls instances from 2021-09-14 to 2021-09-15 -p doc_test_dev -all -limit 10;Sample output:
StartTime RunTime Status InstanceID Owner Query
2021-09-14 11:59:16 0s Success 20210914**************6pr3 ALIYUN$****@test.aliyunid.com
2021-09-14 11:59:20 1s Success 20210914**************6qgr ALIYUN$****@test.aliyunid.com select date_sub(date '2007-02-26', -1);
2021-09-14 12:02:19 1s Success 20210914**************h8o7 ALIYUN$****@test.aliyunid.com select date_sub('2009-03-01 00:00:00', 2);
2021-09-14 12:02:25 0s Success 20210914**************7t42 ALIYUN$****@test.aliyunid.com
2021-09-14 12:02:37 0s Success 20210914**************7pr2 ALIYUN$****@test.aliyunid.com
2021-09-14 12:02:40 0s Success 20210914**************emq2 ALIYUN$****@test.aliyunid.com select date_sub('2015-03-01 00:00:00', 2);
2021-09-14 13:35:42 0s Success 20210914**************1ms2 ALIYUN$****@test.aliyunid.com
2021-09-14 13:35:43 0s Success 20210914**************68o7 ALIYUN$kiki select date_sub(getdate(),1);
2021-09-14 13:45:40 1s Success 20210914**************73wz ALIYUN$kiki select date_sub(getdate(),0);
2021-09-14 13:45:45 0s Success 20210914**************9nm7 ALIYUN$dreak
10 instancesList all user instances in another project today, limited to 5 results:
show p -p doc_test_dev -all 5;Sample output:
StartTime RunTime Status InstanceID Owner Query
2021-09-14 12:02:40 0s Success 20210914**************emq2 ALIYUN$****@test.aliyunid.com select date_sub('2015-03-01 00:00:00', 2);
2021-09-14 13:35:42 0s Success 20210914**************1ms2 ALIYUN$****@test.aliyunid.com
2021-09-14 13:35:43 0s Success 20210914**************68o7 ALIYUN$kiki select date_sub(getdate(),1);
2021-09-14 13:45:40 1s Success 20210914**************73wz ALIYUN$kiki select date_sub(getdate(),0);
2021-09-14 13:45:45 0s Success 20210914**************9nm7 ALIYUN$dreak
5 instancesQuery instance status
Returns the current status of a specific instance.
Syntax
status <instance_id>;Parameters
| Parameter | Required | Description |
|---|---|---|
instance_id | Yes | The unique ID of the instance to query. |
Instance states
| State | Meaning |
|---|---|
Running | The instance is currently executing. |
Waiting | The instance is queued and waiting to run. |
Success | The instance completed successfully. |
Failed | The job failed. No changes were made to the destination table. |
Cancelled | The instance was stopped (for example, by a kill command). |
Terminated | The job has finished (includes Success and some stopped states). |
If the instance belongs to a different user, this command returns an error.
Example
-- Query the status of instance 20131225123xxxxxxxxxxxxxxx.
status 20131225123xxxxxxxxxxxxxxx;Output:
SuccessView running instances
Lists instances currently running in a project, including resource usage and queue position.
Syntax
-- List running instances submitted by you in the current project.
top instance;
-- List all or a limited number of running instances in the current project.
top instance [-all] [-limit <number>];Parameters
| Parameter | Required | Description |
|---|---|---|
-all | No | Return running instances from all users in the project. Default: up to 50 instances. |
-limit number | No | Return the specified number of running instances. |
Output fields: InstanceID, Owner, Type, StartTime, Progress, Status, Priority, RuntimeUsage (CPU/MEM), totalUsage (CPU/MEM), QueueingInfo (POS/LEN).
Example
-- Return the first five running instances in the current project.
top instance -limit 5;Output:
QueueingInstances: 0 total.Stop an instance
Stops a specific instance that is in the Running state.
Syntax
kill <instance_id>;Parameters
| Parameter | Required | Description |
|---|---|---|
instance_id | Yes | The unique ID of the instance to stop. The instance must be in the Running state — otherwise an error is returned. |
kill is asynchronous. The command returns immediately after the system accepts the request, but the distributed job may still be running. Run status <instance_id> to confirm the instance has stopped before proceeding.
Example
-- Stop instance 20131225123xxxxxxxxxxxxxxx.
kill 20131225123xxxxxxxxxxxxxxx;Get job details
Returns job details for a specific instance, including the SQL query, owner, start and end times, and status.
Syntax
desc instance <instance_id>;Parameters
| Parameter | Required | Description |
|---|---|---|
instance_id | Yes | The unique ID of the instance. |
Example
-- Get job details for instance 20150715xxxxxxxxxxxxxxx.
desc instance 20150715xxxxxxxxxxxxxxx;Output:
ID 20150715xxxxxxxxxxxxxxx
Owner ALIYUN$XXXXXX@alibaba-inc.com
StartTime 2015-07-15 18:34:41
EndTime 2015-07-15 18:34:42
Status Terminated
console_select_query_task_1436956481295 Success
Query select * from mj_test;Get job logs
Returns the operational log for a specific instance, including the Logview URL, resource cost, input/output record counts, and Map/Reduce stage details.
Syntax
wait <instance_id>;Parameters
| Parameter | Required | Description |
|---|---|---|
instance_id | Yes | The unique ID of the instance. |
Logview is only accessible for instances created within the last three days. For older instances, retrieve the Logview URL from their logs.
Example
-- Get the operational log for instance 20170925161122379gxxxxxx.
wait 20170925161122379gxxxxxx;Output:
ID = 20170925161122379g3xxxxxx
Log view:
http://logview.odps.aliyun.com/logview/?h=http://service.odps.aliyun.com/api&p=alian&i=201709251611223xxxxxxdqp&token=XXXXXXvbiI6IjEifQ==
Job Queueing...
Summary:
resource cost: cpu 0.05 Core * Min, memory 0.05 GB * Min
inputs:
alian.bank_data: 41187 (588232 bytes)
outputs:
alian.result_table: 8 (640 bytes)
Job run time: 2.000
Job run mode: service job
Job run engine: execution engine
M1:
instance count: 1
run time: 1.000
instance time:
min: 1.000, max: 1.000, avg: 1.000
input records:
TableScan_REL5213301: 41187 (min: 41187, max: 41187, avg: 41187
)
output records:
StreamLineWrite_REL5213305: 8 (min: 8, max: 8, avg: 8)
R2_1:
instance count: 1
run time: 2.000
instance time:
min: 2.000, max: 2.000, avg: 2.000
input records:
StreamLineRead_REL5213306: 8 (min: 8, max: 8, avg: 8)
output records:
TableSink_REL5213309: 8 (min: 8, max: 8, avg: 8)