Guest eksit Posted May 5, 2006 Report Share Posted May 5, 2006 hello. i am having a problem with my testing of cron. i have a ftp script called "backupscript" located in /home/eksit/test/backupscript. the file is executable. this is the file: #!/bin/bash wall A system backup is currently being performed... ftp -in <<EOF open 127.0.0.1 user eksit *** bin hash prompt cd /home/eksit/test2 put testtext bye wall A system backup has completed... Files FTP'ed to Backup Server from su, i do: #crontab -u eksit /home/eksit/eksit so the output of : #contab -l is: # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/home/eksit/eksit installed on Thu May 4 23:17:48 2006) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 19 23 * * * /home/eksit/test/backupscript this script executes nicely manually from a bash prompt. however, it hangs indefinitly when run by cron. any ideas on what i am doing worng? thank you in advance. Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted May 5, 2006 Report Share Posted May 5, 2006 I've found with some jobs that I've had to use the full path to the program command in the script. Eg: /usr/bin/ftp instead of just ftp on it's own. I found my jobs weren't working, and this was why. Although I normally just drop the scripts in /etc/cron.daily instead of setting up crontab. Quote Link to comment Share on other sites More sharing options...
Guest eksit Posted May 6, 2006 Report Share Posted May 6, 2006 Thank you for your reply. I tried to change the path to /usr/bin/ftp with no result. I see a message that states "You have new mail in /var/spool/mail/eksit". Am I correct in assuming that error output will be mailed here? Please excuse my ignorance, but how do I check this account? I am not familiar at all with sendmail. Also, you stated that you drop your scripts in /cron.daily. Are you able to control when the scripts are executed, if so how? Thanks again for the assistance. Quote Link to comment Share on other sites More sharing options...
tyme Posted May 6, 2006 Report Share Posted May 6, 2006 Am I correct in assuming that error output will be mailed here? Please excuse my ignorance, but how do I check this account? I am not familiar at all with sendmail. open a terminal and run the command: mail for more information on the mail command, as always: man mail Quote Link to comment Share on other sites More sharing options...
Guest eksit Posted May 7, 2006 Report Share Posted May 7, 2006 (edited) Thank you. I wasn't sure which program to man. I solved my problem. My guess is that cron was not able to ftp to 127.0.0.1. When using a remote ftp site, the scheduled script works perfectly. Here is the script in case anybody wants it: #!/bin/bash #backup script for simple ftp transaction scheduled with cron #works with iis installation. substitute username as "anonymous" with an email for the pasword for anonymous connections. #please note that for this example to work, it assumes that the script is located in the same directory as the files to be transferred. # # # #Broadcast Start of Backup wall A system backup is currently being performed... #Mail the Administrator #mail anybody@anywhere.com -s "FTP Backup Done" -v < system.txt #FTP the file to the backup directory on the backup server /usr/bin/ftp -in <<EOF #ip adress of remote host goes here open 192.xxx.xxx.xxx #username and pass go here. i.e., a user named "eksit" with the pass "nobody" would modify the next #line to read "user eksit nobody" user username pass #leave the next three lines alone bin hash prompt #to switch remote directorys: if you had a directory on the remote machine called #"happy", the line would read "cd happy" cd happy #upload file, i.e. for a file called "testtext", the line would read "put testtext" put testtext bye There's alot of comments i put in there for anybody who is learning like i am! Thanks for your time to everyone who replied. Edited May 7, 2006 by eksit Quote Link to comment Share on other sites More sharing options...
Guest eksit Posted May 22, 2006 Report Share Posted May 22, 2006 ok. so i've been working on this job again, and i realized that standard ftp will not upload directories. so after 10 hours, much google and about 64 oz of beer, i present to you a new script! -you must have ncftp installed. standard ftp alone will not allow you to do this properly! #!/bin/bash ncftp -R -u (username) -p (pass) (hostname/ip) / /home/eksit/backup/(directory name) add this to cron , and you are a pimp! im not gonna comment this one becuase im too tired. if you need help, email eksit@adelphia.net. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.