Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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

#!/bin/bash
command=$*

$command &  
wait
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:

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

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

Your Answer

 
discard

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.