We want to run our scripts in multiprocessing mode. Is there any way to check number of instances running for a script
There isn't anything built in, you would need to keep track yourself if it is important how many are running simultaneously.
so every instance started I will have to write pid to file. Also have a validation, that checks the process is still running (procexists). If not then delete it else add to count. rt? or there is better logic?
Correct. That is essentially what the Webinator dispatch script does, although it keeps the pids in a ram table in memory.