Skip to content

Instantly share code, notes, and snippets.

@higemaru
Last active December 19, 2015 18:18
Show Gist options
  • Save higemaru/5997521 to your computer and use it in GitHub Desktop.
Save higemaru/5997521 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -eq 0 ];then
echo 'USAGE: '$0' [second] command....'
exit;
fi
_CMD="$@"
_TIME=5
if [ $# -gt 1 ];then
if [[ "$1" =~ ^[0-9]+$ ]];then
_TIME=$1
_CMD=$(echo $_CMD|sed s/$1//)
fi
fi
#bash -c "sleep ${_TIME}; test -e /proc/$$ && kill -9 $$" &
bash -c 'sleep '${_TIME}'; test ! -z `ps -p '$$' -o"pid="` && kill -9 '$$ &
disown $!
exec $_CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment