Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The place I work at has commands that take a long time to execute.

Is there a command/utility that I can use to notify me when the command execution is over? It could be a popup window or maybe a little sound.

share|improve this question

12 Answers 12

up vote 83 down vote accepted

Generally, if you know this before running the command, you can just start it with:

command; command-after &

This will execute the command-after after the previous command has exited (regardless of its exit code). The & will start it in background.

If you care about a successful or failure exit, respectively use:

command && command-after-only-if-success &
command || command-after-only-if-fail &

If the command has already started you may use job control to suspend it, then return it to the foreground with fg chained with your notification:

# enter Ctrl-z
fg ; command-after

Now … what you want to do after this depends on your environment.

  • On any system, you can "ring" the terminal bell. Depends on your exact system what really works (BSD vs. GNU Linux, etc.), but tput bel should do. I couldn't reliably test it right now, though. Search for "ring bell" to find out more.

  • On Mac OS X, you could use AppleScript to pop up a Finder dialog:

    osascript -e 'tell Application "Finder" to display dialog "Job finished" '

    You could have it say something to you:

    say "Job finished"

    Or you could use Mountain Lion's notification system:

    sudo gem install terminal-notifier # <= only need to do this once
    terminal-notifier -message "Job finished!" -title "Info"
  • In GNOME, zenity can show a GTK dialog box, called from the command line. See also this Stack Overflow question: showing a message box from a bash script in linux. It can be installed through your favorite package manager.

    zenity --info --text="Job finished"
  • Some distributions might have xmessage. Specifically for GTK environments, there is gxmessage.

  • Ubuntu has a notification system that you can trigger with notify-send.

    notify-send "Job finished!"
  • KDE uses kdialog, for example:

    kdialog --passivepopup 'Job finished'
share|improve this answer
Awesome! Thank you! – Utkarsh Sinha Oct 11 '11 at 20:50
Let me know what command you used! I added some other options as well. – slhck Oct 11 '11 at 20:54
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for -… – Utkarsh Sinha Oct 11 '11 at 21:04
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;) – trinth Oct 10 '12 at 18:28
Why are you suggesting that "command-after" should be run asynchronously?  Did you mean to say (command; command-after) &? – G-Man Jun 24 '15 at 3:13

On unix-like systems you can ring the audible-bell:

echo -e "\a"
share|improve this answer
This is really useful in addition to a message notification on mac – Sirens Apr 1 '13 at 18:49
same as tput bel – Dwight Spencer Sep 2 '15 at 18:31

I created a simple tool, for MacOS X, that does exactly this.


$ npm install -g brb


$ sleep 3; brb
share|improve this answer

I have just begun using notifu for desktop notifications from Cygwin. It's a command line notification app for Windows.


ls -l && /c/notifu-1.6/notifu64 /m "This is a simple Notifu message."
share|improve this answer

For Linux, there is a nifty trick to do this automatically without having to type a command for notification every time.

First install autokey. This helps defining actions for different keystrokes.

sudo apt-get install autokey-gtk

Now, define a new phrase in autokey and assign the hotkey as Alt+Enter. Add this phrase:

; notify-send "Job finished!" &

Note that a new line after the first line is important.

Also, add a window filter. I use guake and terminal. Include whatever other terminal you use.


You're done!!

Now, everytime whenever you need to get notifications for a command, run it using Alt+Enter instead of Enter/Return.


share|improve this answer

Although other answers already covered most of the ways to get notifications on a finished job, I want to give my two cents since you asked your question in the following format:

The place I work at has commands that take a long time to execute.

I have the same problem. Sometimes something can run for 15 minutes.

I have the following function in my .bashrc:

# push a notification to your phone. can be handy if you're running a
# build and you want to be notified when it's finished.
push() {
    curl -s -F "token=PUSHOVER_TOKEN" \
    -F "user=PUSHOVER_USER" \
    -F "title=terminal" \
    -F "message=$1" > /dev/null 2>&1

This uses the Pushover app in order to push a notification to my phone. This way I can go to lunch or enter a meeting and still get notified on jobs I started on my computer before I left.

I use it in the following manner:

command_to_run && push "yes! command finished successfully!" || push "awww man! something failed :-("

So, if the command returns a correct exit code, the first push will be executed. On an error, the second one will be executed.

Ofc you need to create a user at Pushover, and register an app to send notifications from

hope this helped!

share|improve this answer
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed? – Edward Falk 12 hours ago

To get a sound notification you can use spd-say "Some text". Example:

some-command; spd-say "Yo"
share|improve this answer
What OS? I don't see it on Mac or Ubuntu – Edward Falk 12 hours ago

If you use csh or tcsh as your interactive shell, you can use the notify command:

% long-running-command &
[1] 14431
% notify %1
(later, when the command finishes)
[1]    Done                          long-running-command

You can achieve a similar effect in bash with set -b or set -o notify.

This probably doesn't meet your requirements, since all it does is print a message; I dont' think it can be configured to pop up a window or ring the bell.

share|improve this answer
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though! – Utkarsh Sinha Oct 11 '11 at 22:20

On systems with 'awk' try

awk 'BEGIN{ print "\a" }'

was the only one to work for me.

share|improve this answer
That's just a verbose way of echoing \a (trinth's answer). – David Richerby Sep 4 '15 at 8:05

If you're using npm then node-notifier provide a cross-platform solution.

notify -t "Agent Coulson" --icon -m "Well, that's new. "


  • Linux KDE

Linux KDE

  • Windows


  • Mac OS


  • Growl


share|improve this answer

I wrote ntfy for exactly this purpose. It is cross-platform and can automatically send notifications when long running commands finish.

If you have Python's pip (most Linux distros and MacOS have it), here's how to install it and enable automatic notifications:

$ sudo pip install ntfy
$ echo 'eval "$(ntfy shell-integration)"' >> ~/.bashrc
$ # restart your shell

Check it out at

In addition to that, it also can:

  • supress automatic notifications when the terminal is in the foreground (X11, iTerm2 & supported and enabled by default)
  • send cloud-based notifications (Pushover, Pushbullet, and XMPP)
  • be used to send notifications when a process ends (not the aforementioned automatic support)
  • manually send notifications (good for use in scripts!)
share|improve this answer

Wish I'd noticed this thread years ago. My solution was essentially the same as slhck's, but I wrote a script. I use it all the time. Posting here to share it.


msg='all done'
if [ "$1" = '-q' ]; then quiet=true; shift; fi
if [ $# -gt 0 ]; then msg="$*"; fi

echo -ne "\x1b]0;$msg\a"
if [ -x /usr/bin/zenity ]; then
  unset WINDOWID
  exec zenity --info --text="$msg"
elif [ -x /usr/bin/xmessage ]; then
  exec xmessage -nearmouse "$msg"
elif [ -x /usr/bin/osascript ]; then
  if ! $quiet; then say "done" &; fi
  osascript -e "tell application \"System Events\" to display dialog \"$msg\""
  echo $msg

One small bit of explanation: the string "\x1b]0;$msg\a" is the ANSI escape sequence to put the message in the title bar of the window from which it was executed. I find it quite handy sometimes to be able to see which window it was that the message came from.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .