I'm just jumping into unix from a different world, and wanted to know if
while true
do
/someperlscript.pl
done
The perl script itself internally has a folder/file watcher that executes when files are changed in the target location.
Is this (while true
) a good idea? If not, what is a preferred robust approach?
TIA
EDIT : Since this seems to have generated a fair bit of interest, here is the complete scenario. The perl script itself watches a directory using a file watcher. Upon receiving new files (they arrive via rsync), it picks up the new one and processes it. Now the incoming files may be corrupt (don't ask.. coming from a raspberry pi), and sometimes the process may not be able to deal with it. I don't know exactly why, because we aren't aware of all the scenarios yet.
BUT - if the process does fail for some reason, we want it to be up and running and deal with the next file, because the next file is completely unrelated to the previous one that might have caused the error.
Usually I would have used some sort of catch all and wrapped the entire code around it so that it NEVER crashes. But was not sure for perl.
From what I've understood, using something like supervisord is a good approach for this.
inotify
API so that you can avoid a busy loop waiting for files to change in your target directory.