how to setup cron to run everytime when new file is generated in drupal files folder
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.