Limit execution time or count
Author: dzuelkeCreated Jan 15, 2026Updated Jan 16, 2026
Labelsnew feature
It would be great if there was a way to limit the number of executions, or the total time elapsed, until a command is no longer executed, and watchexec stops.
This would be especially useful for anything that wraps watchexec for its own purposes and wants to, for example, perform one-off actions (wait until something in the FS changes and execute an action).
So e.g. watchexec --initial-events=create --limit-count=1 <filters> would be used for one-off jobs (see #992 for the --initial-events proposal), and watchexec --limit-time=60sec <filters> would keep calling the program upon changes until 60 seconds have elapsed (both could also be combined).
Source: watchexec/watchexec