Solved

MySQL from crontab

Posted on 2011-09-11
2
576 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
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 77

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access_log 17 100
High Available Storage based on linux 6 69
Exchange 2010 unable to mount DB due to corruption 11 69
Setting up two Raspberry Pi gateways/routers 3 40
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

920 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