Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Feb 242010
 

Flush all MySQL log files

Answer:

MySQL default has several log files such as the error log, query log, and slow query log.

Sometimes, To perform log rotation, it is necessary to tell MySQL stop writing to these old log files, rename it and start over again.

To do so, you can execute the FLUSH LOG command in the MySQL client.

mysql> FLUSH LOG;

As a result, it will causes the MySQL to rename the current error log file with a suffix of -old and create a new empty log file.

Usually you should no need to do it manually, you should use tool such as logrotate .

Reference: http://dev.mysql.com/doc/refman/5.0/en/flush.html

Feb 222010
 

How to escape "-" character at the beginning of filename?

Answer:

Assume you have file named -test.txt, if you want to print it out by the cat command:

# cat -test.txt
cat: invalid option -- '.'
Try `cat --help' for more information.

You will experienced the above error, similar errors will happen with commands such as mv, cp etc.

To correctly handle these kind of files that with file name start with the character -, you need to escape with --

e.g.

#cat -- -test.txt
test