Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 02-19-2011, 07:47 AM   #1
Registered: Aug 2007
Posts: 346

Rep: Reputation: 31
crontab fails but command line works -

Having an odd problem running a mysqldump via crontab. I have the script running on other servers and they work fine, so not sure how to actually troubleshoot, but the script looks like the following;

rm -rf /archives/server_baks/*

if mysqldump -u root --password=pwhere --databases tables_here --add-locks | gzip > /archives/server_baks/mysql.$(date +%Y-%m-%d_%H%P).sql.gz
echo "ERROR: The backup failed."

If I run it as a cronjob as root, it finishes in a second and a 20k file is there. If I run it from the command line as root it does the backup (takes a few minutes) but does complete the backup and can be unzipped and read successfully.

Any ideas why / how?
Old 02-19-2011, 08:12 AM   #2
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137

First you should use absolut paths to the executable programs, because does not know about PATH set in your session. Try again and check if your problem occurs after this change.
1 members found this post helpful.
Old 02-19-2011, 04:18 PM   #3
Registered: Aug 2007
Posts: 346

Original Poster
Rep: Reputation: 31

As much as I would love to say it can't be;

which mysqldump reveals only the one;

and that is in the local path as I can type mysqld <tab> with the autocomplete, but I did update the script to the full path and it worked, so I am still curious, but won't dispute!

Thanks for the basic idea!
Old 02-19-2011, 04:43 PM   #4
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
which finds executables in the PATH environment variable. cron usually runs under a smaller PATH than a login shell.


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] Keyboard problems: virt-manager fails, but kvm from the command line works kenneho Linux - Virtualization and Cloud 1 11-14-2009 11:11 AM
Bash script works from command line, fails from cron cmfarley19 Linux - General 4 08-14-2009 12:24 PM
cron job fails, but command in crontab succeeds when directly entered rmunsch Linux - Server 2 02-16-2009 05:27 PM
Shell pgm works fine in command line but not in Crontab oracledba_raja Linux - General 2 11-24-2006 12:14 AM
shell script works form command line but not form crontab saifee General 1 10-14-2004 10:27 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:29 PM.

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