I would like to write a Linux service using PERL, but don't know how to do. (I know perl)
I have a MySQL database, and need to check it for new records, so I can process them. The service should respond almost instantly, so cron is not a good choice for me and I don't want to use some workarounds in order to run my script every second. Besides, the script is threaded, and may take some time till finish, so cron is not really good choice for me.
So, I have two ways:
A service that queries database at every second and process the new records as they arrive. Or something like MySQL trigger that triggers the script when a new record inserted. However, this should not slow down other software that inserts the records.
What do you suggest me? What is the best way to achieve this?
edit: For example, do I need to do something like this when writing a service?
while(1) { do stuff sleep(1) } and write a simple init script? Is there any more elegant way?
Thanks in advance,