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 01-29-2013, 07:27 AM   #1
raphael75
Member
 
Registered: Jul 2012
Posts: 37

Rep: Reputation: Disabled
rar produces 0-byte file in crontab


I have a .sh script that does a mysqldump of a database, uses RAR to compress it, and then deletes the .sql file.

It works perfectly when I run it manually from the command line, but when it runs in a cron the .rar file is always 0 bytes. I tried having it suppress all output but it didn't make a difference. Here is the file:

Code:
#!/bin/sh
filename="<path>/db_sh"
mysqldump -u <username> -p<password> --all-databases --skip-extended-insert > ${filename}.sql
/rar/rar a -iddpq -ierr ${filename}.rar ${filename}.sql > /dev/null 2>&1
unlink ${filename}.sql
*long path substituted with <path>

What can I do to make the cron version work? Thanks!
 
Old 01-29-2013, 07:31 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,536

Rep: Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440Reputation: 2440
probably you need to use mysqldump with full path. crontab has a special environment.
 
1 members found this post helpful.
Old 01-29-2013, 10:38 AM   #3
raphael75
Member
 
Registered: Jul 2012
Posts: 37

Original Poster
Rep: Reputation: Disabled
Thank you, that fixed it.
 
  


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
[SOLVED] memcpy fails to copy data, but byte by byte assignment work venu_s Programming 7 07-08-2011 04:29 AM
redirect stdout to file produces blank file kissaki Linux - Software 5 01-06-2009 04:28 AM
question on how to rar multiple files into there own rar file steve51184 Linux - Software 13 10-24-2007 05:23 PM
How to open unrar? file.part1.rar - file.part2.rar Maje Linux - Software 4 05-29-2006 02:05 AM


All times are GMT -5. The time now is 10:41 AM.

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