# Error log rotation on crash

**URL:** <https://forums.percona.com/t/error-log-rotation-on-crash/1953>\
**Category:** Other MySQL® Questions\
**Created:** [December 20, 2012, 5:43pm UTC](https://forums.percona.com/t/error-log-rotation-on-crash/1953 "2012-12-20T17:43:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HasBlake](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/hasblake/32/860_2.png) [@HasBlake](https://forums.percona.com/u/HasBlake)\
**Post date:** [December 20, 2012, 5:43pm UTC](https://forums.percona.com/t/error-log-rotation-on-crash/1953/1 "2012-12-20T17:43:32Z")

</div>

So I’ve noticed that if the server ends in a non-graceful fashion, i.e., crashes randomly, it creates a new error log file with the date appended.

In our environment, errors log to /var/log/mysql/mysqld.log and we have a logrotate config set to rotate weekly and then gzip. However, if the server crashes, everything before that crash is automatically moved to mysqld.log-YYYYMMDD. Not only does this break the logrotate config, but sometimes the server continues to log to the mysqld.log-YYYYMMDD file.

Is this the intended behavior on crashes? It would be nice to have everything continue to log to the main file, as that’s how flush logs has behaved for awhile now.

---

<div class="post-metadata">

**Author:** ![niljoshi](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/niljoshi/32/16889_2.png) [@niljoshi](https://forums.percona.com/u/niljoshi)\
**Post date:** [December 24, 2012, 4:20am UTC](https://forums.percona.com/t/error-log-rotation-on-crash/1953/2 "2012-12-24T04:20:31Z")

</div>

Hi,

From [http://dev.mysql.com/doc/refman/5.5/en/log-file-maintenance](http://dev.mysql.com/doc/refman/5.5/en/log-file-maintenance). html seems that mysql doesn’t create those mysqld.log-YYYYMMDD files, if you flush the logs mysql creates mysqld.log-old. so that other file is being created by some other thing. and logging to a mysqld.log-YYYYMMDD needs a change on my.cnf and a server restart, is not a dynamic variable.

AFAIK, that behavior is not mysql standard. something else (a patch) or another software is doing that. Can you provide the MySQL server version, OS version and the script which you are using to log rotate?
