egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

crontab.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
CP1832
Halfop


Joined: 09 Oct 2014
Posts: 68

PostPosted: Fri Jan 30, 2015 11:32 am    Post subject: crontab.tcl Reply with quote

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"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber