how to setup cron to run everytime when new file is generated in drupal files folder I created webform and saving submitted data into text file in drupal files folder. A remote script performs calculations and outputs new text file  to the same folder . I want cron to run everytime text file is generated, so that i can print result from text file to webform and also save them to database

So far i created custom module for webform and used hook_cron() as shown below

function simulation_ignition_view_cron()
 {
  $uri = 'default/files/simulation/generatedfile.txt';
  if (file_exists($uri)) {
  drupal_set_message("hello cron");
 }
}


Please let me know if my explanation is not clear and please give some suggestions
I want cron to run everytime text file is generated


I think you're misunderstanding what cron is. Cron is 


  a command to an operating system or server for a job that is to be executed at a specified time.


It doesn't respond to file system triggers, it's a scheduled task.

If a file is created as part of the normal Drupal content add/edit, you can just implement hook_file_insert():

function MYMODULE_file_insert($file) {
  if ($file-&gt;uri == 'foo') {
    // Do something.
  }
}


If you want to start the scheduled jobs running in that hook you can use drupal_cron_run(), but it would probably make more sense not to involve cron in this.