Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I tried to follow the mysql history file with:

tail -f ~/.mysql_history

in another window I entered as the same user:

mysql -u someotheruser -p

and none of the following commands are shown in my tail. when I exit the mysql console there is still nothing shown in the tail -f, although, when I cat the history file, I see, that there are new entries at the end of the file

share|improve this question

1 Answer 1

up vote 7 down vote accepted

That is because mysql fully recreates .mysql_history file during its run.

So when you run cat ~/.mysql_history after mysql execution, you're looking completely different file. Not the one tail is reading.

You can easily check it with a simple test:

 $ ls -li .mysql_history 
6685441 -rw------- 1 user user 1570 Sep 15 21:26 .mysql_history
 $ mysql i_test
...
mysql> Bye
 $ ls -li .mysql_history
6685474 -rw------- 1 user user 1592 Nov 29 20:27 .mysql_history

as you can see inode differs. So that's the answer.

share|improve this answer
5  
GNU tail has a -F option that will periodically reopen the file by name so that it can work in cases like this. –  Mark Plotnick Nov 29 '13 at 19:40
    
That will add the whole file to the tail -F each time you leave the mysql console. Isn't there another way to watch the progress om the file? maybe with watch somehow? –  rubo77 Nov 29 '13 at 19:58
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.