CP1832 Halfop
Joined: 09 Oct 2014 Posts: 68
|
Posted: Fri Jan 30, 2015 11:32 am Post subject: crontab.tcl |
|
|
Hi guys:
I've created a tcl script that will run once a day and delete log files when they are older than 30 days, instead of using crontab. If anyone would like to use it, here it is: | Code: | foreach bind [binds logs] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
bind time - "00 00 * * *" logs
proc logs {min hour day month year} {
putlog "Deleting logs"
foreach file [glob -nocomplain -directory logs *.log] {
set time [clock seconds]
set log [file mtime $file]
set diff [expr ($time - $log) / 86400]
if {$diff >= 30} {
putlog "Deleting $file"
file delete -force $file
}
}
}
putlog "Crontab loaded" |
|
|