All Products
Search
Document Center

Simple Log Service:List scheduled SQL jobs

Last Updated:Dec 10, 2025

Call the ListScheduledSQLs API to list scheduled SQL jobs.

Note

The Simple Log Service (SLS) SDK for Scheduled SQL is no longer updated. Use the Alibaba Cloud SDK to manage Scheduled SQL.

image

Prerequisites

Parameter description

def list_scheduled_sql(self, project_name, offset=0, size=100):

Request parameters

Parameter

Type

Required

Description

Example

project_name

String

Yes

The name of the project.

demo-test-project

offset

int

No

The line from which the query starts. Default value: 0.

0

size

int

No

The line at which the query ends. Default value: 100.

100

Response parameters

For information about the response parameters, see ListScheduledSQLs.

Sample code

import os
from aliyun.log import LogClient


def main():
    # In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
    accessKeyId = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
    accessKey = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')

    # Specify a Simple Log Service endpoint.
    endpoint = "cn-hangzhou.log.aliyuncs.com"
    project_name = "demo-test-project"

    client = LogClient(endpoint, accessKeyId, accessKey, "")

    res = client.list_scheduled_sql(project_name)
    res.log_print()


if __name__ == '__main__':
    main()

Sample response

ListScheduledSqlJobResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '1005', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Fri, 01 Nov 2024 07:13:47 GMT', 'x-log-time': '1730445227', 'x-log-requestid': '67247FABD2F425CB26C87523'}
count: 1
total: 1
jobs: [{'name': 'test-001', 'type': 'ScheduledSQL', 'apiType': 'ScheduledSQL', 'status': 'ENABLED', 'description': 'Create a scheduled SQL task', 'displayName': 'test-001', 'state': 'Enabled', 'recyclable': False, 'schedule': {'type': 'FixedRate', 'delay': 0, 'interval': '60s', 'runImmediately': False, 'timeZone': '+0800'}, 'configuration': {'roleArn': 'acs:ram::141******5616316:role/aliyunserviceroleforslsaudit', 'destRoleArn': 'acs:ram::141******5616316:role/aliyunserviceroleforslsaudit', 'sourceLogstore': 'test-logstore', 'destEndpoint': 'cn-hangzhou.log.aliyuncs.com', 'destProject': 'demo-test-project', 'destLogstore': 'test-logstore2', 'fromTimeExpr': '@m - 5m', 'toTimeExpr': '@m', 'maxRunTimeInSeconds': 1800, 'maxRetries': 10, 'forceComplete': False, 'fromTime': 1730444541, 'toTime': 0, 'sqlType': 'searchQuery', 'resourcePool': 'enhanced', 'dataFormat': 'log2log', 'version': 0, 'script': '* | select *', 'parameters': {}}, 'scheduleId': 'f3bc8ba5ccb******c68f34ea8fdcf8d', 'createTime': 1730444990, 'lastModifiedTime': 1730444990}]

Process finished with exit code 0

References