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?
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.
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.
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..
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.
@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/):
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.
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 .