Skip to content

Instantly share code, notes, and snippets.

@mattchainsaw
Created May 11, 2016 21:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattchainsaw/2d6f211647b855056bf6161c587e132c to your computer and use it in GitHub Desktop.
Save mattchainsaw/2d6f211647b855056bf6161c587e132c to your computer and use it in GitHub Desktop.
Notification of job completion
#!/bin/bash
#
# This still works with piping and redirection of output.
# Ex)
# bash run.sh ./long_computation > long_computation.out
if [ ! $1 ]
then
echo "Usage: $0 <command>" >&2
fi
while [ $1 ]
do
exec 3>&1
notify-send "Job Complete" "Took `(time $1) 2>&1 >&3 3>&-|
grep 'real' | sed 's/[^0-9]*//'`" | cat 3>&-
exec 3>&-
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment