tellmewhen
Tell me when another program has finshed. Tell me when it started, tell when it finished. Tell me how long it took. Tell me the output and if it failed.
I created this utility because I had long running database scripts that I wanted a completion notification for – including a summary of the time and exit code. I had done this various ways in the past by using bash and other shell utilities. This program captures all of the features and behavior I wanted without having to script it from scratch again every time I needed it.
- YML Based Configuration in an rc file
- easy default configuration
- sends email
- includes start/stop/elapsed timing
- success/fail based on exit code
- watch an already running process (by pid)
- released as a gem so it’s easy to use/install
Installation
gem install tellmewhen
Configuration
Configuration Defaults:
---
notify-via: email
email:
from: `echo $LOGNAME`@`hostname
to: `echo $LOGNAME`@`hostname
Configuration is then merged from $HOME/.tellmewhenrc
if the file exists in $HOME
. Configuration is also merged from ./.tellmewhenrc
in the current directory, if the file exists. This allows you some flexibility in overriding settings.
Usage
Usage: ./tellmewhen command args...
-v, --[no-]verbose Run Verbosely.
-c, --config=file Use alternate configuration file.
-p, --pid=pid Wait for <pid> to terminate.
-e, --exists=file Wait for <file> to exist.
-m, --modified=file Wait for <file> to be modified.
-t, --timeout=seconds Wait for up to <seconds> seconds for the command before sendin a 'pending' notification.
-w, --write-config=file Write [fully merged] configuration to <file> (NB: will not be clobber).
Examples
./tellmewhen 'sleep 3; ls'
./tellmewhen -p 12345
./tellmewhen -e some-file.txt # await existance
./tellmewhen -m some-file.txt # await update
You can also have ‘pending’ notifications so that you know things are still going:
./tellmewhen -t 2 'sleep 5; ls'
Produces 2 emails. The pending mail is:
Subject: When! [NOT] I'm _still_ waiting for sleep...
Body:
Just wanted to let you know that:
sleep 5; ls
Is _STILL_ running on your-host.com, it has not exited. You did want me to let you know didn't you?
I started the darn thing at Tue Jan 25 23:25:01 -0500 2011 (1296015901) and it has taken a total of 3 seconds so far.
Just thought you'd like to know. I'll continue to keep watching what you asked me to. (boor-ring!)
Cordially,
Tellmewhen
P.S. stderr says:
--
--
P.S. stdout says:
--
--
And a final mail when it completed:
Subject: When! SUCCESS for sleep...
Body:
Just wanted to let you know that:
sleep 5; ls
completed on your-host.com, with an exit code of: 0
It started at Tue Jan 25 23:25:01 -0500 2011 (1296015901), finished at Tue Jan 25 23:25:06 -0500 2011 (1296015906) and took a total of 5 seconds.
May your day continue to be full of win.
Sincerely,
Tellmewhen
P.S. stderr says:
--
--
P.S. stdout says:
--
README.textile
Rakefile
bin
foo
tellmewhen.gemspec
--
Contributors
Kyle Burton <[email protected]>
License
Patches Welcome
I’d like to clean up the internals: how emails are composed.
I’d like to support other notification channels, like Instant Messaging or SMS. Multiple at one time, controlled through the configuration yaml.
What would you like?
Changes
1.0.1 Tue Jan 25 18:16:01 EST 2011
Update runner to compare File.basename($0) == File.basename(FILE) so it can run when installed as the gem.
1.0.0 Mon Jan 24 21:15:32 EST 2011
Initial Release