LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-19-2011, 08:47 AM   #1
sir-lancealot
Member
 
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."
fi

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, 09:12 AM   #2
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

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, 05:18 PM   #3
sir-lancealot
Member
 
Registered: Aug 2007
Posts: 346

Original Poster
Rep: Reputation: 31
[solved]

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

which mysqldump reveals only the one;
/usr/local/mysql/bin/mysqldump

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, 05:43 PM   #4
Berhanie
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.
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:28 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
Open Source Consulting | Domain Registration