1

I want to run a SSH command using a cron and I want to extent this cron by adding autocommit=0 So that auto commit is disabled.

How can I achieve this?

Command:

mysql dbname -u dbuser -p'password' < /path/to/the/sqlscript/var/sql/stock.sql
steffen
  • 16,138
  • 4
  • 42
  • 81
JGeer
  • 1,768
  • 1
  • 31
  • 75
  • Assuming you cannot modify the SQL script? What you need to do is probably concatenate `SET autocommit = 0;` and your script and send the concatenation result to stdin, so this is more of a bash question than a MySQL question. – Mikhail Burshteyn Sep 18 '18 at 20:53

1 Answers1

2

There are many ways to prepend / append a string to a file. A simple way:

(echo "set autocommit=0;"; cat stock.sql; echo "set autocommit=1") | mysql dbname -udbuser -ppassword
steffen
  • 16,138
  • 4
  • 42
  • 81