# lftp using sftp in a cron job



## Frankhelm (Jun 5, 2014)

Hi,

this is my first post on this forum.

I have trouble running my script as a cron job.

This is my script sftp.sh

```
#!/bin/sh
cd /usr/local/epost/mirror/

lftp -e "mirror -vnR /usr/local/epost/mirror/in && bye" sftp://name:password@000.000.000.000 >>/usr/local/epost/mirror/feedback/log.txt

lftp -u name,password -p 22 -e "mirror -vn feedback && bye" sftp://000.000.000.000 >>/usr/local/epost/mirror/feedback/log.txt
```


When I run it as `./sftp.sh` it runs perfect. But as a cronjob nothing happens. I know that cron is running the script because I had a `mkdir` outside of the lftp and the folder was created. Also if I try to log to log.txt the log wil be createt but with no content.

I run this script as root.

I hope someone kan help me with this. 

Thanks.


----------



## SirDice (Jun 5, 2014)

Use the full path to the executables. Crontab has a very limited PATH.


----------



## Frankhelm (Jun 5, 2014)

Thanks

but if i do 

/usr/local/bin/lftp -e "mirror -vnR /usr/local/epost/mirror/in && bye" sftp://nameassword@000.000.000.000 >>/usr/local/epost/mirror/feedback/log.txt

i get this message.

 mkdir `in' [Delaying before reconnect: 59]

when the counter gets to 0 it starts from the beginning over and over again.


----------



## SirDice (Jun 5, 2014)

I would suggest using scp(1) instead of the lftp/sftp(8) combination to transfer the file.


----------

