-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurge.pl
executable file
·34 lines (25 loc) · 953 Bytes
/
purge.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl
# Name of camera.
$cam = $ARGV[0];
# Keep this many days
$days = $ARGV[1];
for ($i = $days + 10 ; $i > $days ; $i--) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time - $i * 60 * 60 * 24);
$location = "~/security/".$cam."/".($year + 1900)."/".sprintf("%02d", ($mon + 1))."/".sprintf("%02d", $mday);
$cmd = "rm -rf ".$location;
`$cmd`;
$camlocation = "~/security/".$cam;
$cmd = "find $camlocation -type d -empty -delete";
`$cmd`;
}
$days = 0;
for ($i = $days + 10 ; $i > $days ; $i--) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time - $i * 60 * 60 * 24);
$location = "~/ramdisk/".$cam."/".($year + 1900)."/".sprintf("%02d", ($mon + 1))."/".sprintf("%02d", $mday);
$cmd = "rm -rf ".$location;
print "\n".$cmd."\n";
`$cmd`;
$camlocation = "~/ramdisk/".$cam;
$cmd = "find $camlocation -type d -empty -delete";
`$cmd`;
}