Solved

MySQL from crontab

Posted on 2011-09-11
2
573 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 142

Accepted Solution

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

Assisted Solution

by:arnold
arnold earned 100 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now