I have the following command
mysql -u root -ppass myDB -e "select * from table limit 10;"
which when I run it from a linux server it works normally (10 tuples are displayed)
When the following is added in a bash file
echo 'mysql -u root -ppass myDB -e select * from table limit 10;' >> /root/test.log
nothing happens. In the log file, only the echo string is being displayed.
Can someone please help me in this?
that is because you just
echoyour command as a string and redirect the output of echo to the log file. You do nothing else 😉Just run the command as you would do on the command line and redirect the output of
mysqlcommand (instead ofecho) to your logfile: