| View previous topic :: View next topic |
| Author |
Message |
Car`a`carn Voice
Joined: 01 Apr 2007 Posts: 5
|
Posted: Sun Apr 01, 2007 6:39 pm Post subject: Bot stops logging when erasing the log file |
|
|
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 |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Sun Apr 01, 2007 7:35 pm Post subject: |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Apr 01, 2007 7:45 pm Post subject: |
|
|
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 |
|
 |
Car`a`carn Voice
Joined: 01 Apr 2007 Posts: 5
|
Posted: Mon Apr 02, 2007 3:56 am Post subject: |
|
|
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 . 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 . |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Mon Apr 02, 2007 4:11 am Post subject: |
|
|
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 |
|
 |
Car`a`carn Voice
Joined: 01 Apr 2007 Posts: 5
|
Posted: Mon Apr 02, 2007 4:24 am Post subject: |
|
|
| 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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Apr 02, 2007 10:43 am Post subject: |
|
|
@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 |
|
 |
Car`a`carn Voice
Joined: 01 Apr 2007 Posts: 5
|
Posted: Mon Apr 02, 2007 10:48 am Post subject: |
|
|
nml375: I'll look into it and do some experiments. Thanks . |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Mon Apr 02, 2007 8:38 pm Post subject: |
|
|
| 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 |
|
 |
Car`a`carn Voice
Joined: 01 Apr 2007 Posts: 5
|
Posted: Tue Apr 03, 2007 2:59 am Post subject: |
|
|
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 . |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Apr 04, 2007 12:19 am Post subject: |
|
|
That's why god created /bin/date, so you can distinguish filenames with dates  |
|
| Back to top |
|
 |
|