This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

crontab.tcl

Support & discussion of released scripts, and announcements of new releases.
Post Reply
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

crontab.tcl

Post by CP1832 »

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: Select all

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"
Post Reply