Can a Cron job be set up to FTP?

KimberH

Member
Dec 29, 2013
24
3
53
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
 

andrew.n

Well-Known Member
Jun 9, 2020
281
56
28
EU
cPanel Access Level
Root Administrator
Yes it is possible.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,304
1,250
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