Operating System - HP-UX
1753767 Members
5948 Online
108799 Solutions
New Discussion юеВ

Re: 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