Server Fault is a question and answer site for system and network administrators. 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

I'm often issuing commands that take some time. For example downloading something using a console download app. If I want to be noticed when the command has finished, I usually do something like this:

$ <do something>; echo '<do something> has finished' | osd_cat

Then I can switch to another window and do something else meanwhile. When it's done, I'll be noticed.

Now my problem is that I'm lazy. Oh well. I just don't want to type this everytime. So I wonder if there's a daemon that could watch running processes and trigger some actions when the processes finish.

I would like config options so I could have control on:

  1. filtering the processes to be watched (for example, watch processes that run at least for a minute)

  2. customizing the command to perform when a process has finished

share|improve this question

You could try using Bash's "wait" command to write a little wrapper script Something like:


$command &  
osd_cat "$command has finished"

The wait command causes the script to pause until all child processes have returned an exit code. You could also add a little timeout to make sure that you don't wait too long

share|improve this answer

How about just a simple shell script that does the long command for you. Maybe something like this:

# tellme: run a command and tell me when it's done
if [ $# -gt 0 ]; then
    if $*; then
        echo "'$*' has finished" | osd_cat
        echo "'$*' has finished with errors" | osd_cat
    echo "usage: $0 <command>"

Then, you would just run this command:

tellme <do something>

Granted, it isn't a daemon, so I don't think it will help you for things started in the background (e.g. from cron), but it should do the job for interactive commands.

share|improve this answer
It's still more to type than just the command itself. That's why I'm wondering if there's a daemon that would work absolutely transparently. – Anonymous Jul 23 '09 at 17:18

Maybe it's not a daemon, but it serves the same purpose for me. zsh has scriptable hooks executed right before and right after executing any command. You can make them measure wallclock time and run any action (here: notify-send) if the last executed command was long enough. The following in an excerpt from my ~/.zshrc:

preexec () {
  ZSH_CMD_START_TIME="$(date +%s)"
precmd () {
  [[ -n "$ZSH_CMD_NAME" ]] && {
    ZSH_LAST_TIME=$(($(date +%s) - $ZSH_CMD_START_TIME))
    [[ $ZSH_LAST_TIME -gt 60 ]] && [[ -n "$DISPLAY" ]] && { which >/dev/null notify-send } && {
      notify-send --urgency=low --category=zsh --expire-time 1500 "ZSH:" '`'"$ZSH_CMD_NAME"'`'" took $ZSH_LAST_TIME seconds."
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.