Skip to content

Instantly share code, notes, and snippets.

@tluyben

tluyben/count.pl

Created Dec 31, 2020
Embed
What would you like to do?
counting new files per minute over 3k in a directory
#!/usr/bin/perl
$p = -1;
$intr = 2;
@minute = ();
while(1) {
$c = `find ./scraped -size +3k -ls|wc -l`;
chomp($c);
if ($p>=0) {
$t = $c - $p;
push @minute, $t;
if (scalar(@minute)>60/$intr) {
shift @minute;
}
$tm=0;
foreach(@minute) {
$tm+=$_;
}
print "Per $intr s: $t, per minute: $tm, per 15m: ".($tm*15).", per 30m: ".($tm*30).", per hour: ".($tm*60)." total current: $c\n";
}
$p = $c;
sleep $intr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment