Scheduled Jobs
Scheduled Jobs are automated scripts that can perform a specific task at a specific time or on a recurring schedule. Eg - Sending notifications to users whose subscription has expired.
Fill the following details to create a schedule job :- Name - name of the schedule job Active - chech / uncheck to activate / deactivate the job. State - state shows whether the job is running or not. Job Type :- Interval - job will run every interval defined by the cron pattern. On Demand - job will run only with manual intervention whenever you want it to run. Schedule - provide cron pattern here like */1 * * * * which means job will run every minute.
Below is a sample code to delete stale logs and events generated by the platform.
const DB = ob.db.getConnection();
DB.collection('pltf_log').deleteMany({
created_on: {
$lte: new Date(
ob.moment
.tz('Asia/Kolkata')
.subtract(15, 'days')
.startOf('day')
.toISOString()
)
}
});
DB.collection('pltf_event_queue').deleteMany({
created_on: {
$lte: new Date(
ob.moment
.tz('Asia/Kolkata')
.subtract(15, 'days')
.startOf('day')
.toISOString()
)
}
});
DB.collection('pltf_transaction').deleteMany({
created_on: {
$lte: new Date(
ob.moment
.tz('Asia/Kolkata')
.subtract(100, 'days')
.startOf('day')
.toISOString()
)
}
});
DB.collection('deleted').deleteMany({
created_on: {
$lte: new Date(
ob.moment
.tz('Asia/Kolkata')
.subtract(90, 'days')
.startOf('day')
.toISOString()
)
}
});
Last updated
Was this helpful?