New to Kestra?
Use blueprints to kickstart your first workflows.
Orchestrate scheduled NFS scratch space cleanup with Kestra. Verify the mount, list stale files across a shared NFS path, delete them safely, and alert on failure.
When several workers write to the same NFS mount for scratch space, cleanup usually falls between the cracks: no single worker owns the directory, so partial and orphaned files from crashed or forgotten jobs just accumulate. This blueprint runs a nightly janitor pass with the io.kestra.plugin.fs.nfs plugin. Before it deletes anything, it checks that the configured path genuinely resolves to an NFS mount, a safety net against a misconfigured path silently pointing at local disk instead of the shared volume everyone actually uses.
verify_nfs_mount (io.kestra.plugin.fs.nfs.CheckMount) checks /mnt/nfs/data-pipeline/scratch and reports whether it's really an NFS mount along with the detected fileStoreType.abort_if_not_nfs (io.kestra.plugin.core.execution.Fail) fails the flow immediately if isNfsMount is false, so a bad mount configuration stops the run instead of deleting files somewhere unintended.list_stale_scratch_files (io.kestra.plugin.fs.nfs.List) enumerates files matching .tmp, .part, or .scratch extensions recursively, sorted oldest first (sort: LAST_MODIFIED_ASC), capped at 1,000 results.log_stale_file_count records how many files were found before anything is removed, so the execution log always shows what the next step is about to touch.delete_stale_scratch_files (io.kestra.plugin.fs.nfs.Delete) removes every matching file recursively, with errorOnMissing: false so an already-clean mount doesn't fail the run.notify_cleanup_complete posts the removed file count to Slack; the errors block posts a separate alert if the mount check, listing, or delete step fails.CheckMount) before the recursive delete runs, so a misconfigured path fails loudly instead of deleting the wrong files.find -mtime script with a single, observable, alertable flow.A cron find -delete on one worker only cleans up what that worker can see, and if the NFS mount silently falls back to local disk, it deletes the wrong files with no warning. Kestra centralizes the job as a single flow with a mount safety check before the delete, structured logs of exactly what was found and removed, and an errors block that guarantees a failed mount check or a failed delete surfaces in Slack rather than in a forgotten cron log on one of many worker hosts.
/mnt/nfs/data-pipeline/scratch, reachable from the Kestra worker that runs this flow.SLACK_WEBHOOK_URL: Slack incoming webhook URL.SLACK_WEBHOOK_URL to your Kestra namespace.fs.nfs tasks if your scratch directory lives somewhere other than /mnt/nfs/data-pipeline/scratch.verify_nfs_mount reports isNfsMount: true for your environment.Schedule trigger and watch the Slack channel for the first automated run.lastModifiedTime output against a retention window before deleting, instead of relying on extension matching alone.abort_if_not_nfs fires, since that usually signals an infrastructure misconfiguration worth immediate attention.list_stale_scratch_files-style task against a different shared path to cover more than one scratch directory in the same nightly run.Schedule trigger with a Flow trigger so cleanup runs right after the last daily worker job finishes instead of on a fixed clock time.