If I execute
tee /tmp/script.log
source /root/myscript.sql
I get the log in script.log
and in my current prompt session.
I want to execute myscript.sql
and don't show anything in my prompt, only save it in script.log
I've tried mysql -s (--silent), but then no log is generated in script.log
.
I need to use source
command, mysql < myscript.sql
is not userfull because it leave the session when its finish, and I have flush tables with read lock
command in the end of the script, if the session leaves, flush tables with read lock
is terminated.
Because
read
is pausing waiting for input, the input tomysql
doesn't finish, andmysql
doesn't exit. So the lock held byFLUSH TABLES WITH READ LOCK
stays active as long as you want.When you want to terminate the
read
, just hit return. Or type anything, as long as it doesn't cause an error as input tomysql
.If you want it to terminate itself after say 60 seconds, you could alternatively do this: