1

I've created a passwordless sftp script to download the file from another server and set a cron job to daily, but, as i checked, files are not up-to-date which means the script didn't run in cron job, so I checked the cron logs using grep "sftpscript.sh" /var/log/cron and saw that the cron job did run as per scheduled, but, the files is not downloaded/updated. What could be the problem here? Thanks.

Cron schedule (crontab -e):

0 8 * * * /directory/of/script.sh

Here's my script:

#!/bin/bash

echo "get file*" | sftp $username@$ipaddr:$external_path/
mv file* ./directory

closed as off-topic by Jakuje, lgeorget, Satō Katsura, Jeff Schaller, roaima Apr 5 '17 at 11:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – Jakuje, lgeorget, Satō Katsura, Jeff Schaller, roaima

  • What errorrs you get? – Jakuje Apr 5 '17 at 6:40
  • Cross post on SU – Jakuje Apr 5 '17 at 6:43
  • @Jakuje No error prompt, its just that, the script is not running if set in cron job – Dan Apr 5 '17 at 7:15
  • Cron has its logs, where you can see what happened. If not, increase log level or log by yourself (redirect the stderr to some file). – Jakuje Apr 5 '17 at 7:16
  • As I meantioned in the post, I do checked the cron logs by running the command: grep "script.sh" /var/log/cron and saw that the cron run as scheduled, however, no changes happen on the files, no updates etc. – Dan Apr 5 '17 at 7:54

Browse other questions tagged or ask your own question.