Safe S3 cleanup after successful Nextflow run on Seqera AWS Batch

Hi Team,

We have added a post‑run cleanup script in our Nextflow workflow.onComplete{} block to automatically delete S3 input and intermediate folders only when the pipeline fully succeeds on a Seqera Cloud AWS Batch compute environment.
We want community validation that our approach is safe and recommended.
Our logic includes:

Cleanup runs only if workflow.success == true
Cleanup runs only if at least one task executed (checked via execution trace)
Cleanup enabled only when params.enable_cleanup = true
S3 deletion uses aws s3 rm --recursive s3:///…
Local work/ remains on Batch workers (not deleted)

Looking for confirmation on:

Whether workflow.onComplete{} is the correct mechanism for conditional cleanup in Seqera Cloud
Whether trace‑file + success guard is a valid best‑practice
Any recommended alternative patterns for safe S3 cleanup in managed Batch environments

Want to ensure we follow community‑approved methods before enabling this in production.

I believe it’s expected to use Life cycle rules to clean up cloud caches

Looking for a way to trigger a Nextflow cleanup process (deleting input files) only after the entire workflow completes successfully—any ideas or best practices to handle this efficiently? - #10 by Charles_A_Roy has posted their solution