Issue
I'm setting up for a cron job , in the cronjob.sh i need to tranfer the csv file from server sftp to ftp server , any idea or solution?
Solution
First write a shell script (.sh) file that does the job.
Assuming both your servers are linux nodes with scp enabled, try a bash script like this:
#!/bin/bash
# we assume ssh gen-rsa is used to generate id_rsa_1 and id_rsa_2
# for username1 and username2 for host1 and host2 respectively.
cd /path/to/id_rsa/files
# download the file
scp -i id_rsa_1 usename1@host1:/path/to/your/csv/file.csv ./
# upload the file
scp -i id_rsa_2 ./file.csv username2@host2:/path/to/destination/directory/
The above can be run via commandline as:
chmod 755 my_bash.sh
./my_bash.sh
Verify if the file transfer is working.
Then, invoke my_bash.sh in your crontab -e editor.
Answered By - Edward Aung