Skip to content

Instantly share code, notes, and snippets.

@Shinpeim
Created November 4, 2011 18:36
Show Gist options
  • Save Shinpeim/1340110 to your computer and use it in GitHub Desktop.
Save Shinpeim/1340110 to your computer and use it in GitHub Desktop.
時間かかってるプロセスを監視して終わったときgrowlに通知するやつ。 $ watch.pl <pid> みたいにして使う
#!/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