Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a process that starts with an end user copying picture files to a Ubuntu folder over ftp using filezilla software. On the other hand I have a batch file that gets executed using CRON it is scheduled to be executed at midnight.

My problem is that sometimes the amount of pictures is huge and the ftp process is still running at midnight causing a mess with the pictures in the end.

I would like to fix this by triggering the bash script when the ftp process is over. Is there a way to do this?

Edit: the ftp server I am using is the one that comes with xampp 1.6 which is proftpd

share|improve this question
    
Package name of the FTP server you are using? –  Tim Jan 10 '12 at 18:12
    
What FTP daemon? It is possible that the daemon you are using has some kind of hooks for AV scanning or other post-upload events. –  Zoredache Jan 10 '12 at 18:15
    
@tim the ftp server I am using is the default that comes with xampp 1.6 which is proftpd, hope this helps –  user743736 Jan 12 '12 at 17:17
add comment

1 Answer

@Zoredache's idea is probably the cleanest; an ftpd hook that triggers after upload completion.

Otherwise, off the top of my head, a quick hack would be to simply wrap your cron script in something which checks to see if an ftpd process is running. If so, wait() on the pid. This will block your processes' execution until the ftpd process terminates. Note that there's a race condition here, as another ftpd process can spin up while your script's executing.

Alternatively, you could write a small daemon and use the inofity system in the 2.6 kernel to watch your upload your directory, and process any files with a modified time < some threshold; basically a 'best guess' file completion hook.

share|improve this answer
    
I like Zordache's idea of using a post upload hook, I looked the proftpd documentation and I notice they have something called mod_exec, any thougths on this? –  user743736 Jan 13 '12 at 18:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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