Solved

MySQL from crontab

Posted on 2011-09-11
2
580 Views
Last Modified: 2013-11-22
I created a file named "dbrun.sh":
mysql -u zooph -ppass123 -h m.example.com zooph_db < /usr/home/zooph/cron/cron.sql > /dev/null
touch /usr/home/zooph/cron/cron.txt

Open in new window


When I run the file like this the MySQL queries in the MySQL get exicuted:
sh dbrun.sh

Open in new window

However when the crontab does NOT run the SQL dump:
*/1 * * * * sh /usr/home/zooph/cron/dbrun.sh

Open in new window

The "touch" command works but not the MySQL dump.
0
Comment
Question by:hankknight
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 total points
ID: 36519200
possibly because the mysql is not in the path?
try to modify dbrun.sh so that you specify the full path name ...
0
 
LVL 78

Assisted Solution

by:arnold
arnold earned 100 total points
ID: 36519279
If you want something to run every minute, just use * versus */1
But as angelIII pointed out the location of mysql might not be in the path and
/bin/sh instead of sh or add to the top of your script:
#!/bin/sh
and change mode of the file to 755.

/usr/bin/mysql
/usr/local/bin/mysql should be used instead of the mysql you have.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question