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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script not working in crontab

Status
Not open for further replies.

Kipper

Technical User
Jan 21, 2002
47
GB
I've got the following script, mysql_cron_bkup, to backup a database:

#!/bin/bash
date=`date +%d%m%y`;
filename="bugs$date.sql";
mysqldump -u bugs --password=bugs --opt bugs > /usr/local/mysql/backups/$filename;

crontab:

10 0 * * 6 cd /usr/local/mysql/backups; ./mysql_cron_bkup

When it runs in crontab, it creates a file with a size of 0 bytes. However, when I execute it at the command-line or with 'at', it works fine. Its permissions are 755.

Can anyone help? ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.
 
I wonder if cron has the same env path as you?. Try adding the path to mysqldump in the script and see if that works.
 
I don't think the PATH is the problem, since I have /mysql/bin declared in /etc/profile. I'll give it a try anyway. ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.
 
Any specific reason for doing the cd first and the calling the script?

If not, have you tried running it from the crontab with the full path? (/usr/local/mysql/backups/mysql_cron_bkup)
IBM Certified Specialist - MQSeries
IBM Certified Specialist - AIX 5 pSeries System Administration
 
Yes I have and that did not work either. ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.
 
Can anyones else help with this? ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.
 
Just had a thought. Does Linux have an event viewer like Windows where I can check to see if any errors have been generated? ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.
 
/var/log/messages is the main system log. You can check /etc/syslog.conf to see where and what is being logged on the system.

ChrisP
 
thx. ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.
 
Unfortunately, the cron log only contains the execution record and there aren't any errors in the message logs. :-( ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top