I have created a class that does a lot of different things. One of these thing is launching an external exe-file (windows), using wsh shell instead of phps exec(). My problem is that I do not know how long time the exe-file will use, it can be everything from 5 seconds to 30 minutes. A web user will not want or be able to wait for 30 minutes, so I was thinking about quitting the operation after 30 seconds and put the stuff to be done in a queue, which a scheduled job using the same class can do as a background process.
Is there a way of knowing that the execution of the external exe has used 30 seconds, and then launch a "timeout-function" which will put some stuff in the db to let the background process know something is in the queue, and then exit the current script?