P
P
pashaxp2013-08-14 18:06:07
Automation
pashaxp, 2013-08-14 18:06:07

Bash scripts and stream redirection

There is a bash script fragment that does the following

/usr/bin/mysqldump -u dbuser -p"userpass" database > db.sql


If we run the command from the console, we see errors when creating a dump, if any.

How to redirect error output in a bash script during dump execution to a file?
So that, for example, what we would see if we ran the command from the console was saved to the /tmp/log file.

/usr/bin/mysqldump -u dbuser -p"userpass" database > db.sql  > /tmp/log


If we set it this way, then the same thing gets into /tmp/log as into db.sql - an sql query, but it is necessary that mysqldump error logs get there.
I would be grateful for any advice.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
3
3vi1_0n3, 2013-08-14
@pashaxp

/usr/bin/mysqldump -u dbuser -p"userpass" database > db.sql 2>error.log

K
krasulya, 2013-08-14
@krasulya

try (difference in "2")

/usr/bin/mysqldump -u dbuser -p"userpass" database > db.sql  2> /tmp/log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question