LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 06-13-2007, 12:04 PM   #1
madhavr
LQ Newbie
 
Registered: Nov 2003
Distribution: Fedora 6
Posts: 10

Rep: Reputation: 0
ftp via cron


hello,

im trying to ftp my database dump file automatically.

just to clarify the cron works fine.

the contents of the script looks like below:

Quote:
#!/bin/sh

date=`date '+%d-%m-%y'`

mysqldump -A --user=user--password=pass| /usr/bin/bzip2 -c > /home/backup/db/$date.sql.bz2

ftp -in $server <<EOF

quote USER $username

quote PASS $password

prompt

binary

mput /home/backup/db/*

quit

EOF
the server, username and password are all entered directly but i've just replaced them with dummy variables to show this script.

this does the dump fine but never does the ftp part. however if i copy and run this directly via ssh console it works fine. i dont know which log file i should be looking at for possible errors as i dont see one for ftp in /var/log/.

any help would be much appreciated.
 
Old 06-13-2007, 12:32 PM   #2
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
I've had trouble with scripts running out of crontab if I did not put the full qualified path for stuff. I notice you do not have the fully qualified path for ftp ...mysqldump is working from cron without the full path, so it must be okay.

you should have a /var/log/cron
and /var/log/messages

either of those log files might help you further debug the issue.
 
Old 06-14-2007, 12:01 AM   #3
p_s_shah
Member
 
Registered: Mar 2005
Location: India
Distribution: RHEL 3/4, Solaris 8/9/10, Fedora 4/8, Redhat Linux 9
Posts: 237
Blog Entries: 1

Rep: Reputation: 34
Password is passed wrongly. You can's use <i> PASS $PASS </i>, while you are using non interactive FTP.

Try following :

Code:
ftp -n -d -v $ftphost << END | tee /tmp/ftplog.txt
user $ftpuser $ftppass
prompt
binary
mput /home/backup/db/*
bye
END
If you still find problem, you can check ftp log in /tmp/ftplog.txt

Please check similar thread :
http://www.linuxquestions.org/questi...d.php?t=550671
 
Old 06-17-2007, 04:34 AM   #4
gtparks
LQ Newbie
 
Registered: Dec 2005
Distribution: RedHat, CentOS, Fedora, Ubuntu
Posts: 10

Rep: Reputation: 2
If you use a ~/.netrc file, you can avoid all the password stuff (it's kept in the .netrc file). The "| tee" scheme is great for debugging. I'd suggest adding "2>&1 | tee" to capture stderr as well as stdout.
 
  


Reply



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
In plesk , I wish to have a backup cron job, ftp back up file to another ftp server? muskiediver Linux - General 6 07-16-2009 03:13 AM
FTP cron job dad1001 Linux - Networking 1 07-22-2006 11:42 PM
Automating an FTP transfer with cron? Seventh Linux - Newbie 3 01-17-2006 06:39 PM
cron+script+FTP tommytomato Linux - General 6 01-13-2006 11:53 PM
FTP Script will not run from Cron grhansen Programming 12 01-13-2006 04:13 AM

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

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