How to Update or Delete Scheduled Jobs Under /var/eventing/scheduled-jobs When Cron Expression Changes
Hi Team
I am working with scheduled jobs in AEM and have encountered a scenario where a job is initially configured with a 10-minute cron expression. Later, the requirement changes, and the cron expression needs to be updated to trigger the job every hour. The cron expression is sourced from the OSGi configuration.
However, when the cron expression is updated, the existing job under /var/eventing/scheduled-jobs is not modified. Instead, a new job node is created with the updated cron expression, resulting in both the old (10-minute) and new (1-hour) jobs running simultaneously. This is not the intended behavior.
I attempted to delete the old job programmatically, but it appears that the APIs do not provide a straightforward way to remove or update these job nodes directly.
Although it is possible to manually delete the old job or modify the job directly in CRXDE, this approach is not a sustainable solution and is not considered a best practice.
I would appreciate guidance on how to automate the process of updating an existing scheduled job's cron expression or how to properly remove the old job node from /var/eventing/scheduled-jobs when the cron expression changes.
Thank you for your assistance!
Regards
Keerthana S