Can a Cron job be set up to FTP?

KimberH

Active Member
Dec 29, 2013
34
6
58
cPanel Access Level
Website Owner
Hi, I've been learning how to set up cron jobs. Before I do more research, can a cron job be set up to do a FTP job? FTP the files in a folder to an external folder?

Thank you
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
Yep, entirely possible, you'd make a bash script with the information you wanted for the FTP login, then create the cron. Something like the following:

https://www.linuxquestions.org/questions/aix-43/setting-up-a-cron-for-transferring-a-file-through-ftp-at-5-pm-daily-934622/ said:
Code:
#!/bin/bash

filename="/home/<username>/thefile"
hostname="ftp.myhost.com"
username="username"
password="password"
ftp -un $hostname <<EOF
quote USER $username
quote PASS $password

binary
put $filename
quit
EOF
Then add the cron job