Ask Your Question
3

While executing stored procedures in the background through a Bash script, what is the process for flushing stdout in MySQL?

asked 2021-07-04 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-04-08 18:00:00 +0000

bukephalos gravatar image

To flush stdout in MySQL, you can use either the "FLUSH" or the "SELECT SLEEP(0)" command.

For example, in a Bash script, you can use the following command to flush stdout before executing the stored procedure:

echo "FLUSH;" | mysql -h $HOST -u $USER -p$PASS $DB

This will send the "FLUSH" command to MySQL to flush the output buffer before executing the stored procedure.

Alternatively, you can use the following command to flush stdout before and after executing the stored procedure:

echo "SELECT SLEEP(0);" | mysql -h $HOST -u $USER -p$PASS $DB

This will execute a command that causes a delay (in this case, zero seconds), but also forces MySQL to flush the output buffer. By running this command before and after executing the stored procedure, you can ensure that all output is flushed to stdout.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-07-04 11:00:00 +0000

Seen: 10 times

Last updated: Apr 08 '23