سؤال

I am building a bash script that makes a lot of use of mysql. Now I want to add it a possibility to log down any comments/errors that come from the database. lets admit the simple case.

mysql -uuser -ppass dbase <<EOF
insert into table (col) values ("$val");
EOF

how would this look with logging to /var/log/mylamescript ? I want to log warnings, errors, etc ... anything except "successful"

هل كانت مفيدة؟

المحلول

You just have to redirect the standard error appending to your log file:

mysql -uuser -ppass dbase <<EOF 2>> /var/log/mylamescript 
    insert into table (col) values ("$val");
EOF
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top