Forum Moderators: phranque

Message Too Old, No Replies

FTPS program using a CRON Job ?

How to run a Secure FTP program using CRON

         

jpmadmin

2:02 am on Jan 7, 2012 (gmt 0)

10+ Year Member



I need to run a PHP script with FTP commands over a Secure (SSL) Connection (i.e. FTPS).

Is there a way to run FTPS automatically with a CRON Job ?

CRON doesn't use a Browser Session -- the Programs are called/executed directly on the Linux Server as follows:

/usr/bin/php /home/DomainDirectory/public_html/test_ftp.php

Frank_Rizzo

6:00 pm on Jan 8, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does this work directly from the console?

/usr/bin/php /home/DomainDirectory/public_html/test_ftp.php

If yes then that is what you need to run in the cron job.

crontab -e

and add that in at the required times.

Do you have to use the php file? You could use sftp in batch mode. Create a batch script (login in to the target server, change directories, put file) and then run the batch from cron.

jpmadmin

2:51 pm on Jan 9, 2012 (gmt 0)

10+ Year Member



Hi Frank,

Thanks for your reply.

Yes -- the command runs from the console.

However, I currently have this setup in the "Simple Control Panel" - to run at the appropriate times.

What does "crontab -e" do ? How would I add that to my Simple Control Panel ?

Do you have a sample working script using SFTP ?

Yes I have to run the php file -- it's 1st creating the file to FTP.

I don't believe my server is setup properly to support/run SFTP and I'm not sure how to setup the appropriate Libraries (I'm a bit of a Newbie to Linux/CentOS).

Thanks again.

Frank_Rizzo

4:43 pm on Jan 9, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



crontab -e will edit the cron jobs. It's a bit fidly so it's best to use a control panel.

I don't know about simple control panel. I just looked at the demo on a setcronjob com site and it looks as if you can only run a cron against a http: address.

What you need to do is to run the cron via the linux command line. This is what crontab -e will set for you but it is a difficult editor to understand - you may not know how to save and exit so find an online guide to using crontab -e to edit cronjobs.

----

Check if you have sftp on the server

sftp

should show you a list of options.

The simplest way to transfer a file is with

sftp username@remoteserver:file.txt

If you can get that to work in the command line then that would be the simplest cron job to setup.

You can create a batch file if you want to submit more than one fine, manipulate directories etc.