How to set time limit only for one php file?
Don't do this. While it is possible to do this, using set_time_limit(0) is giving your server free rein to execute indefinitely; you're setting yourself up for server instability. 

If you have a large workload that you need to execute in a Drupal context, use its Queue API. This API will let you queue up a list of items to process (i.e. the table rows you're checking) and process them with a queue worker (i.e. the task that "does the checks" and generates user notifications).

You can find many examples of creating a queue and a queue worker by searching Google for [drupal 8 queue api].