On Monday 24 February 2003 11:59 am, Thomas Adam wrote:
--- Matt Johnson <johnsonmlw@yahoo.com> wrote: > Hi folks,
Hello,
I've written a script to upload some static html pages to an ftp server. I've used .netrc for the connection settings. It all works well when I run the script.
Nice call. The use of .netrc is a good idea, especially for autoloading of settings.
Now, I've put that script in /etc/cron.daily and on the RedHat system I've got, that should run at 4am. But it doesn't work. The logs show that it fails to login to the remote FTP system when the job is run by cron.
:-) Hmmm, which user are you using to ftp the files
over? And which ftp daemon are you using? I'd be more inclined to write another "wrapper" shell script that actually "su"'s to the "ftp" user and then uploads it that way.
The reason most likely, as to why it doesn't work is because all crom services that are ran, are ran as "root" which would give you permission errors.
One other possibility is the environment. When you log in, a number of environment variables are set, such as $HOME. This almost certainly isn't being set for the cron job. If use use su - <username> -c <scriptname> in your cronjob, then minus sign tells su to use that user's environment and most of the variables required are initialised.
To summarise... The script works if I now sit here and type:
/etc/cron.daily/webupdate
It doesn't work if I change the system time to 4am and watch it try! Fails to login.
See above.
I've checked the permissions on the script in /etc/cron.daily are the same as the others in that directory.
HTH,
-- Thomas Adam
===== Thomas Adam
"The Linux Weekend Mechanic" -- www.linuxgazette.com
__________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com
-- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000