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 

Bot stops logging when erasing the log file

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Eggdrop Help
View previous topic :: View next topic  
Author Message
Car`a`carn
Voice


Joined: 01 Apr 2007
Posts: 5

PostPosted: Sun Apr 01, 2007 6:39 pm    Post subject: Bot stops logging when erasing the log file Reply with quote

I've a little problem where my bot is logging a channel and I have it keeping all the logs from everyday. Now it's so that I want the logs to be removed the 1st every month. So good and well I set a crontab to delete all log files in the log directory 1min after midnight, which worked nicely. The problem with this is that the current log (e.g. channel.log20070401) the bot was using was deleted as well. I knew of this of course but figured it wasn't a problem since the bot would re-create the file and keep logging from a minute past midnight on the first and until the next month.

As it seem the bot didn't write at all and it didn't even re-create the todays file at all. Doing a rehash didn't help either so I had to comment out the log-row in the conf file and rehash and then reverse it and rehash again for it to re-create it and continue logging.

So my question is. Shouldn't the bot see that the todays (current) file it was writing the logs to is missing and re-create it and keep storing the conversations in the logs. I guess I could solve my refresh the logs every month problem with a number of crontabs but wondering if there is a way to get the bot to rec-reate the log file if being erased?
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Sun Apr 01, 2007 7:35 pm    Post subject: Reply with quote

Try restarting the bot.

Do some forum searching and you should find further topics covering varying aspects of your post.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Apr 01, 2007 7:45 pm    Post subject: Reply with quote

I have a faint memory that eggdrop does not close logfiles once created/opened, until it rotates logs. Hence you'd get the situation you've described if you delete the file while it's still opened.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Car`a`carn
Voice


Joined: 01 Apr 2007
Posts: 5

PostPosted: Mon Apr 02, 2007 3:56 am    Post subject: Reply with quote

Alchera: I believe I also tried to restart the bot with no success, can't swear on it but would like to find a solution without having to restart it Smile. I have searched the forum a lot with no luck.

nml375: Yes it creates the file when a new day starts but the file that I erased was never re-created of course.

Thanks for the replies Smile.
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Apr 02, 2007 4:11 am    Post subject: Reply with quote

Copy the file to a different name for your backup, then do 'echo > original-filename' to wipe out the contents of the original. That should do the trick. Either that or look at the log zipper tcl, which will make archives for every day and delete old archives every xx days..

http://members.dandy.net/~fbn/logzipper.tcl.txt
Back to top
View user's profile Send private message
Car`a`carn
Voice


Joined: 01 Apr 2007
Posts: 5

PostPosted: Mon Apr 02, 2007 4:24 am    Post subject: Reply with quote

rosc2112: Yeah I have been pondering of doing something like the first one you said. Would mean more crontabs though but seems as if there is no other way right now. Thanks.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Apr 02, 2007 10:43 am    Post subject: Reply with quote

@Car`a`carn:
Indeed it is not, as eggdrop never closed the file. Hence, the next logentry will use the already opened filehandle instead doing another call to open (and thus not creating a new file).

One way of doing it would be using the evnt-binding to trigger on log-rotation, and have a script delete each file (after testing that it's not today's logfile). Something like this, I guess (code has'nt been tested, and assumes there's only logfiles in ./logs/):
Code:

bind - evnt "logfile" clearlogs
proc clearlogs {event} {
 if {[clock format [clock seconds] -format "%e"] != 1} {
  return
 }
 set match "*[clock format [clock seconds] -format ".log%Y%m%d"]"
 foreach file [glob "./logs/*"] {
  if {[string match $match $file]} {continue}
  file delete -- $file
 }
}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Car`a`carn
Voice


Joined: 01 Apr 2007
Posts: 5

PostPosted: Mon Apr 02, 2007 10:48 am    Post subject: Reply with quote

nml375: I'll look into it and do some experiments. Thanks Smile.
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Apr 02, 2007 8:38 pm    Post subject: Reply with quote

Car`a`carn wrote:
rosc2112: Yeah I have been pondering of doing something like the first one you said. Would mean more crontabs though but seems as if there is no other way right now. Thanks.


No need for multiple crontabs, you can either seperate commands within your single crontab line with semi-colons, or even easier, make a little shell script then invoke that from cron.
Back to top
View user's profile Send private message
Car`a`carn
Voice


Joined: 01 Apr 2007
Posts: 5

PostPosted: Tue Apr 03, 2007 2:59 am    Post subject: Reply with quote

rosc2112: Yes but since I will need to remove all files without the current one, the name will variate depending on the month I need to run different commands through crontabs (or a script) to trigger on different dates Smile.
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Apr 04, 2007 12:19 am    Post subject: Reply with quote

That's why god created /bin/date, so you can distinguish filenames with dates Smile
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 -> Eggdrop Help 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