Skip to Content
1
Mar 18 at 04:49 PM

Prevent Cronjob Log-Files from being saved or delete them after job completed based on condition.

108 Views

Hi

I have a cronjob that checks on the presence of some files on the filesystem. Depending on whether or not those files are present I would like to decide whether or not a logfile should be generated for the current cronjob executions.

The initial idea was to simply override JobPerformable.isPerformable() in my Job implementation, however it looks like this does not prevent the log files from being generated and attached to the cronjob.

Another idea was to use the existing CronJob.logToFile property. Unluckily, this property is evaluated before the cronjob executes though.

I guess it would also be acceptable to simply delete the generated file + removing it from CronJob.logFiles after it has executed based on the final CronJobStatus. I am not sure where I could do that though. It seems like Interceptors do not get called when CronJob.logFiles is modified. Is there any way to achieve what I want without overriding Jalo logic? I want to avoid that at all cost.

Thanks a lot in advance.