Skip to content

Instantly share code, notes, and snippets.

@tluyben
Created December 31, 2020 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tluyben/1ed5aa46bb12ab21c98136f050dcc21e to your computer and use it in GitHub Desktop.
Save tluyben/1ed5aa46bb12ab21c98136f050dcc21e to your computer and use it in GitHub Desktop.
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