LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rar produces 0-byte file in crontab (https://www.linuxquestions.org/questions/linux-newbie-8/rar-produces-0-byte-file-in-crontab-4175447677/)

raphael75 01-29-2013 06:27 AM

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!

pan64 01-29-2013 06:31 AM

probably you need to use mysqldump with full path. crontab has a special environment.

raphael75 01-29-2013 09:38 AM

Thank you, that fixed it. :)


All times are GMT -5. The time now is 08:48 PM.