0

I have a pre-registration web app that appends ID numbers to a file 'tmp/data.txt'. The main accounting app has a function to process the file, read the ID's and add registrants.

Is there a way to automate that function whenever file 'tmp/data.txt' changes?

verlager
  • 794
  • 5
  • 25
  • 43
  • you can listen for changes in `php` with https://www.php.net/manual/en/function.inotify-init.php. A simpler appraoch if you have access to cron is to make a cronjob that checks for changes in the file each minute, register any ids it finds and then clear the file. it sounds like you are using a file in place of a database – chiliNUT May 07 '21 at 02:01
  • Thank you for your succinct and extreme relevant response. I will ask exactly how to do that in another post. – verlager May 07 '21 at 07:33
  • 1
    Lot of related questions here that may be useful: https://stackoverflow.com/questions/540339/how-to-check-if-directory-contents-has-changed-with-php, https://stackoverflow.com/questions/13002348/is-there-a-way-to-detect-changes-in-a-folder-using-php-on-both-windows-and-linux, https://stackoverflow.com/questions/10356092/php-auto-detect-when-if-files-have-been-updated ... – Don't Panic May 07 '21 at 07:55
  • @verlager you're welcome! In case it was unclear, I want to clarify my last comment "it sounds like you are using a file in place of a database" meaning that you might want to look into using a database to store the IDs rather than a text file. Also, seconding that Don't Panic has listed some good resources for file watching in php. – chiliNUT May 08 '21 at 02:58

0 Answers0