Operating System - HP-UX
1819932 Members
3509 Online
109607 Solutions
New Discussion юеВ

sftp cron job not working

 
Rocky Lavoie_1
Advisor

sftp cron job not working

Hi all,
I'm trying to atoumate aa sftp file transfer to run as a cron job. If I run it interactively, it works fine.
sftp -b /home/rocky.coned.sftp rocky@sftp.remoteserver.com

coned.sftp looks like this:
put /home/rocky/coned.csv
quit

No error in cron log. Trying to run it as user rocky. Set up job using crontabs -e
Thanks,
Rocky
11 REPLIES 11
Dennis Handly
Acclaimed Contributor

Re: sftp cron job not working

What does your mail say is wrong?
You probably need an absolute path for sftp.
Rocky Lavoie_1
Advisor

Re: sftp cron job not working

Hi,
I tried it with absolute path and still not working. No message in mail.
Thanks,
Rocky
Suraj K Sankari
Honored Contributor

Re: sftp cron job not working

hi,

for sftp the first command you have to give absolute path like /usr/bin/sftp

Suraj
Rocky Lavoie_1
Advisor

Re: sftp cron job not working

Hi,
Typo in first post

/usr/bin/sftp -b /home/rocky/coned.sftp rocky@sftp.remoteserver.com

coned.sftp looks like this:
put /home/rocky/coned.csv
quit

Thanks,
Rocky
Arturo Galbiati
Esteemed Contributor

Re: sftp cron job not working

Hi,
try
/usr/bin/sftp -b /home/rocky/coned.sftp rocky@sftp.remoteserver.com 1>tmp/sftp.log 2>&1

and post the content of /tmp/sftp.log

HTH,
Art
T G Manikandan
Honored Contributor

Re: sftp cron job not working

why dont you use scp instead of sftp ,

scp rocky@sftp.remoteserver.com:
Jozef_Novak
Respected Contributor

Re: sftp cron job not working

Not 100% sure on this, but doesn't sftp need a terminal associated with it ? That would explain the cron job failure.

J.
Ganesan R
Honored Contributor

Re: sftp cron job not working

Hi Rocky,

It suppose to work if you have configured password less login between source and remote server for rocky user.

We have similiar kind of setup and it is working. Try like this...

#vi /home/rocky/putjob

sftp rocky@sftp.remoteserver.com <<**
lcd /home/rocky
put coned.csv
**

:wq!

put the file putjob on crontab something like this..

30 * * * * /home/rocky/putjob >> /home/rocky/putjob.log 2>&1

Best wishes,

Ganesh.
Rita C Workman
Honored Contributor

Re: sftp cron job not working

Here's a thought...albeit not sftp.

Have your tried just using 'scp' instead?

Regards,
Rita
Steven E. Protter
Exalted Contributor

Re: sftp cron job not working

Shalom,

scp is a better tool for this job. Rita hits the nail on the head.

scp -p /home/rocky.coned.sftp rocky@sftp.remoteserver.com:///home/rocky/coned.csv

Before trying either, use this document to set up password free access properly.

http://www.hpux.ws/?p=10

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rocky Lavoie_1
Advisor

Re: sftp cron job not working

Hello All,
Thanks for the replies.
I solved the issue. I was trying to execute the command in the "rocky" crontab file. I put the command in a file name coned.cron and gave it a chmod 700. I put the coned.cron file in the "rocky" crontab and it worked. I think it didn't like the space in the command.
Thanks for your help.
Rocky