I have an online graphics script that receives heavy traffic. Sometimes several visitors are running the script at the same time, and this crashes my Unix server. I need to modify the script so that only one instance can run, and keep the other instances on hold until the first is finished. I have done some research, and most are using file locking. I don't think I need to lock the file. I need to lock the whole script. And, if I lock the script from the other users, will that terminate their input?
I have some ideas. Please tell me if this would be efficient.
Each time the script is run, store the input from each user in a text file on a separate line. The script would then read the data from the first line and run the graphics routine. At the end of the script it would delete current line, and then run the script again from the next line of input until all input is exhausted.
If you have a more efficient way (and I'm sure you do), please advise.
Thanks in advance!