Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Path issue with script to run MySql command 1

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi all

Mysql newbie so please be gentle.[smile]
Code:
mysql -uroot -pPassword mydatabase < /var/data/backup/mydatabase.sql
correctly restores a MySql database from a backup when run in the terminal.

Want to run this ultimately as a cron job, but
Code:
#! /bin/bash

/etc/init.d/mysql -uroot -pPassword mydatabase < /var/data/backup/mydatabase.sql
does not work.

Would appreciate the error(s) being corrected.

TIA



FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
feherke

Thanks for your reply.

If the script file is run, the terminal window simply flashes momentarily, where as in the terminal with '--verbose' in the command, you can observe the progress of the restore.

I am unaware as to how to find the relevant logfile, assuming there is one, or how to output the error(s) to a file?

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
Its likely producing an error, but in common Terminal Window operation for a few years now in both Windows an Linux, the Terminal Windows that are open from a shortcut, or batch file etc.., will self close when the execution of said shortcut or file is done.

To see what is actually happening open a terminal window the normal way, and from that terminal window call your job file.

You'll likely get to see the error which, unless its a formatting issue when you copied and pasted the command here, I'd wager is caused by the fact that your input file's path seems to be on another line which breaks the command.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
feherke

Thanks for that, well spotted, it now works correctly.

vacunita

Thanks for your reply

The error message produced running the script that way still did not give much of a clue - it was concerned with using service(8) utility, e.g. service mysql -uroot, etc. [dazed]

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top