I have a multi part question for a php script file. I am creating this file that updates the database every second. There is no other modeling method, it has to be done ever
The simplest way to ensure only one copy of your script is running is to use flock() to obtain a file lock. For example:
So basically you'd have a dummy file set up where your script, upon starting, tries to acquire a lock. If it succeeds, it runs. If not, it exits. That way only one copy of your script can be running at a time.
Note: flock() is what is called an advisory locking method, meaning it only works if you use it. So this will stop your own script from being run multiple times but won't do anything about any other scripts, which sounds fine in your situation.