Create a Cron Using Cron Expressions
Use this SDK to implement crons to schedule the submission of jobs to job pools. However, the configuration of the cron will be defined using regex-like expressions called Cron Expressions.
# create function job meta
job_meta = {
'job_name': 'test_job', # set a name for the job
'target_type': 'Function', # set the target type as Function for function jobs
'target_name': 'target_function', # set the target function's name (optional) (either target_id or target_name is mandatory)
# 'target_id': '123467890', # set the target functions's Id (optional) (either target_id or target_name is mandatory)
'jobpool_name': 'test', # set the name of the function jobpool (optional) (either jobpool_name or jobpool_id is mandatory)
# 'jobpool_id': '1234567890' # set the Id of the function jobpool (optional) (either jobpool_name or jobpool_id is mandatory)
'job_config': {
'number_of_retries': 2, # set the number of retries
'retry_interval': 15 * 60 # set the retry interval
}, # set job config - job retries => 2 retries in 15 mins (optional)
'params': {
'arg1': 'test',
'arg2': 'job'
} # set params to be passed to target function (optional)
}
# create expression cron
expression_cron = job_scheduling.CRON.create({
‘cron_name’: ’expression_cron’, # set a name for the cron (unique)
‘description’: ’expression_cron’, # set the cron description (optional)
‘cron_status’: True, # set the cron status as enabled
‘cron_type’: ‘CronExpression’, # set the cron type as Calendar for daily, monthly and yearly
‘cron_expression’: ‘0 0 * 1 1’, # set the cron expression
# ’timezone’: ‘America/Los_Angeles’, # set the timezone (optional)
‘cron_detail’: {}, # set the cron details
‘job_meta’: job_meta # set function job meta
})
Last Updated 2025-06-20 16:21:48 +0530 IST
Yes
No
Send your feedback to us