Create a One-Time Cron
The Cron component is used to schedule the submission of a job to the job Pool. Using the following SDK, you will be able to create a cron that will schedule a job submission only once.
Note: The following SDK is written for a job that will trigger a Job Function. To make the SDK compatible for the other types, you need to replace the value with proper Job Pool ID, or Job Pool Name, and provide the appropriate Target Name, or Target ID.
copy// create function job meta const jobMeta = { 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 one time cron details const oneTimeCron = { cron_name: 'one_time', // set a name for the cron (unique) description: 'one_time_cron', // set a description for the cron (optional) cron_status: true, // set the cron status as enabled cron_type: 'OneTime', // set the cron type as OneTime cron_detail: { time_of_execution: Math.floor(Date.now() / 1000) + (60 * 60) + '', // set the execution time as UNIX timestamp // timezone: 'America/Los_Angeles' // set the timezone (optional) }, job_meta: jobMeta // set the function job meta }; // create one time cron const cronDetails = await jobScheduling.CRON.createCron(oneTimeCron);
Note: We urge you to use this SDK to configure only Dynamic Crons. Use the UI Builder to configure Pre-defined Crons.
Last Updated 2025-06-20 16:21:48 +0530 +0530
Yes
No
Send your feedback to us
Skip
Submit