At 3:09 PM -0500 2000-01-07, Charles Kirby wrote:
>If you do shut down mysqld, then you can do whatever you like, since
>it'll append if the log is there, and it'll create a new log file
>otherwise.
>Even if it IS running, I find there's no problem doing "cp /dev/null
>blah.com.log", since this will null out the file without affecting the
>file's i-node status. This is the simplest solution I'd say. If I want
>to save the file without stopping the daemon, I copy the log elsewhere
>(and later zip it), and then I can /dev/null it. If there's activity
>while you're doing this, you'll lose some lines of log file.
>If you "mv" the log file... I notice the file will continue to be written
>to, regardless of the name of the file :) Not a good method.
>
>ck
Actually, that is a good method, it just needs another step. Under UNIX,
if a process has a file open, it will continue to be able to write to the
file , even if the file is renamed or removed. That's because the name
just points to an inode (the underlying storage), and renaming/removing
doesn't affect the underlying storage. Renaming just changes the name,
and removing just removes the pointer to the storage (the storage isn't
removed until the last pointer goes away *and* the file is closed).
You can use this behavior to your own advantage:
mv log log.0 # rename log file
mysqladmin flush-logs # flush the log files
The flush-logs step will tell the server to close the log files and
reopen them. Since you've renamed the original log file, the server
will open a new fresh file named "log" and you can then do whatever
you like the "log.0".
>
>On Fri, 7 Jan 2000 apocoliptica@stripped wrote:
>
>> I noticed my mysql log file is getting fairly big.
>> Does the mysqld have to be shut down prior to successfully deleting the log?
>> Recalling the procedure for apache logs, I wanted to ask before acting...
>>
>> Thanks,
>> Apoc
>>
>>
>>
>> --
>> ---------------------------------------------------------------------
>> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>> posting. To request this thread, e-mail mysql-thread23433@stripped
>>
>> To unsubscribe, send a message to:
>> <mysql-unsubscribe-kirbych=shell.monmouth.com@stripped>
>>
>>
>
>
>--
>---------------------------------------------------------------------
>Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>posting. To request this thread, e-mail mysql-thread23438@stripped
>
>To unsubscribe, send a message to:
> <mysql-unsubscribe-paul=snake.net@stripped>
--
Paul DuBois, paul@stripped
| Thread |
|---|
| • logs | apocoliptica | 7 Jan |
| • Re: logs | Charles Kirby | 7 Jan |
| • Re: logs | Paul DuBois | 8 Jan |
| • Re: logs | Sasha Pachev | 8 Jan |