I have an FTP server (Debian) setup where users send JPG images.

I need a process running on the background that every time a picture is sent via FTP a bash script is executed for generating thumbnail files for each image uploaded.

I already have the script that generates the thumbnail, the problem is it needs to be executed manually, but what I want is the script to be executed each time an image file is uploaded.

How can this work?

  • several possibilities, auditd to watch a folder, your ftp daemon allow to execute a script on each upload, or a cron job every minute to generate it every minute or every 5 minutes with a temp image when thumbnail not yet generated – Kiwy Mar 11 '14 at 15:18
  • Not really a duplicate. The other question is more generic, this one is more specific, and can be solved in ways the other can't. – angus Mar 12 '14 at 20:41

Consider using inotifywait

eg watch a directory

inotifywait .

Then create a file in that direectory.

Here's a previous answer from Unix/Linux stackexchange


It depends on your FTP server.

For example, for pure-ftpd, you do it this way:

  1. Set the option CallUploadScript to yes (just create a file called /etc/pure-ftpd/conf/CallUploadScript and write yes in it)
  2. In /etc/default/pure-ftpd-common, add the path to the script you want to run on each upload after UPLOADSCRIPT=.
  3. Restart the service (# service pure-ftpd restart).

Other FTP servers have their own ways. Read the documentation.


Also possible to use ftpwatch ftpwatch - "Notifies you of changes on remote ftp servers"

 # the crontab line
 47 5    * * 7 /usr/bin/ftpwatch

Not the answer you're looking for? Browse other questions tagged or ask your own question.