Created
November 4, 2011 18:36
-
-
Save Shinpeim/1340110 to your computer and use it in GitHub Desktop.
時間かかってるプロセスを監視して終わったときgrowlに通知するやつ。 $ watch.pl <pid> みたいにして使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Proc::ProcessTable; | |
use Mac::Growl; | |
my $pid = shift or die "<usage> $0 pid"; | |
die "bad pid" unless $pid !~ m/[^0-9]/; | |
chomp $pid; | |
while (1) { | |
my $t = Proc::ProcessTable->new; | |
my $found = 0; | |
foreach (@{$t->table}) { | |
$found++ if $_->pid == $pid; | |
} | |
last unless $found; | |
sleep 10; | |
} | |
my $appname = "process watcher"; | |
Mac::Growl::RegisterNotifications($appname, ['alert'], ['alert']); | |
Mac::Growl::PostNotification( | |
$appname, | |
'alert', | |
$appname, | |
"pid $pid done", | |
0, | |
0, | |
undef, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment