Z
Z
zxosa2015-07-05 19:23:37
MySQL
zxosa, 2015-07-05 19:23:37

How to find a new row in a MySQL table and output it to a text file using Bash?

There is a security alarm panel where all alarm events appear as new rows in a table in the MySQL database. How to organize the search for this new line and output it to a text file? Well, there, by means of telegram, on duty on mobile phones through crowns, it’s understandable :).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Fateev, 2015-07-05
@zxosa

Well, this command will output the line with the maximum ID to the file:

mysql -u username -p 'password' -e 'SELECT * FROM table ORDER BY id DESC LIMIT 1' > output.txt

S
Sergey Sergey, 2015-07-05
@hahenty

diff (event select) (old select)
or vice versa.
(grep and awk to taste)

A
AVKor, 2015-07-05
@AVKor

mysql dbname -e "SELECT col1, col2,... FROM tbname WHERE......;" >> query.txt

It's like outputting the result to a text file.
The query itself depends on how your database is set up.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question