pguard is a simple CLI tool for running commands with optional timeouts and graceful shutdown, similar to Unix timeout.
go install github.com/iamBelugax/pguard@latestOr build manually:
go build -o pguardpguard [flags] <command> [args...]--timeout– Maximum runtime (e.g.10s,1m).-1means no timeout.--graceful– Grace period before force kill (default:5s).
Run a command with a timeout:
pguard --timeout=10s sleep 30Gracefully stop a long-running process:
pguard --timeout=1m --graceful=10s my-command --foo bar- Starts the specified command.
- Waits for completion, timeout, or interrupt (
Ctrl+C). - Sends
SIGINTfor graceful shutdown. - Force kills the process after the grace period if still running.