LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2010, 06:04 PM   #1
novice32
LQ Newbie
 
Registered: Apr 2010
Posts: 8

Rep: Reputation: 0
Cron - mysqldump job creates an empty sql file


My cron job is executing the below mysqldump command but it produces an empty sql file. However, when I run from the command line, it works as expected.

Code:
15 6 * * * root mysqldump -uroot -pXXXXXXX mydbname | gzip > /home/dbbackup/db_`/bin/date +\%Y\%m\%d\%H\%M`.sql.gz
I'm on CentOS 5.4 and use "env EDITOR=nano crontab -e" edit my cron (then paste the above command. I'm new to Linux, so forgive me I'm totally missing something here.
 
Old 04-14-2010, 06:19 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Try adding full paths to both executables involved.
 
Old 04-15-2010, 06:05 PM   #3
novice32
LQ Newbie
 
Registered: Apr 2010
Posts: 8

Original Poster
Rep: Reputation: 0
I used the below, but no luck. It's command, however, works on the command prompt.

Code:
15 6 * * * root /usr/bin/mysqldump -uroot -pXXXXXXXX mydbname | /usr/bin/gzip > /home/dbbackup/db_`/bin/date +\%Y\%m\%d\%H\%M`.sql.gz
An sql.gz file was generated, but was empty. I can't see what I'm missing.
 
Old 04-15-2010, 06:10 PM   #4
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,977
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by novice32 View Post
I used the below, but no luck. It's command, however, works on the command prompt.

Code:
15 6 * * * root /usr/bin/mysqldump -uroot -pXXXXXXXX mydbname | /usr/bin/gzip > /home/dbbackup/db_`/bin/date +\%Y\%m\%d\%H\%M`.sql.gz
An sql.gz file was generated, but was empty. I can't see what I'm missing.
Instead of putting the command in the cron; make a script and have the cron fire off the script.

-C
 
Old 04-16-2010, 01:13 AM   #5
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
It is better to create a script to does so,

For this case
1. What about executing this command on Command line? Is it working fine on command line?
2. Did you receive any error ? Try redirecting the STDERR of this command to a file.
3. Do some quick debugging. Remove the gzip and redirect the output to the file? If this works probably gzip is not working as expected or so.
 
Old 04-17-2010, 12:12 PM   #6
novice32
LQ Newbie
 
Registered: Apr 2010
Posts: 8

Original Poster
Rep: Reputation: 0
I created script and executed via cron. It now works. Also, I guess is I didn't need "root" in "15 6 * * * root /usr/bin/mysqldump"

Last edited by novice32; 04-17-2010 at 12:22 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script via cron makes a empty file szczym Programming 7 09-23-2009 03:58 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
aplay -l > message,txt creates empty file milindlokde Programming 5 06-24-2007 01:46 PM
mysqldump data base < filename.sql.gz ?? knockout_artist Linux - Server 7 04-12-2007 09:30 AM
How to create cron job to empty mbox folder/file sjmo2 Linux - General 4 03-23-2006 02:39 PM


All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration