Skip to content

Instantly share code, notes, and snippets.

@Thann
Created January 9, 2020 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thann/71aada0f983f0225b1847c63057e9295 to your computer and use it in GitHub Desktop.
Save Thann/71aada0f983f0225b1847c63057e9295 to your computer and use it in GitHub Desktop.
Runs a command, then kills it after a specified amount of time.
#!/usr/bin/env bash
# Runs a command, then kills it after a specified amount of time.
# USAGE: run4 10m watch date
${@:2} & PIDD=$!;
sleep "$1";
# echo "==== STOPPED ====";
kill -INT $PIDD;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment