2

Is there a way to delete all files from an FTP folder every 30 minutes automatically?

Let's say that my details are the following:

  • Folder: /myfolder

  • Host: xxx.xxx.xxx.xxx

  • Username: myname

  • Password: mypassword

Thanks in advance!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
vaspant
  • 65
  • 3
  • 11

2 Answers2

2

It's not really clear what do you ask for.

But if you want to automate the deletion via FileZilla, you cannot. FileZilla does not support any automation/scripting.

You have to use another FTP client. On Windows, you can use WinSCP.

A simple batch file (.bat) to delete files from FTP folder using WinSCP scripting is like:

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://myname:mypassword@ftp.example.com/" ^
    "rm /myfolder/*" ^
    "exit"

To schedule the batch file run, use the Windows scheduler. See WinSCP guide to scheduling


The WinSCP can even generate a script template from an imported FileZilla session.

For details, see the guide to FileZilla automation.


(I'm the author of WinSCP)

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
1

make a file abc.php and write this code

array_map('unlink', glob("/myfolder/*"));

after that schedule a corn for hit this file every 30 min

abhayendra
  • 197
  • 6
  • Thanks for your help. Can you provide any details about scheduling a corn? I have not experience on that. – vaspant Oct 06 '16 at 18:36
  • if using VPS then read this link `https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-on-a-vps` – abhayendra Oct 06 '16 at 18:47