2

I have set of some entries in my database to run some scripts in php. So i will run a cron file every few mins to see if for next few mins i have some scripts to run, i will trigger them, what i am wondering what happens if i have a script to be executed at 12:10 which will execute in 5 mins, what happens if i have another request to run the same script at 12:12 while the execution of the first script is not finished yet. Is the file locked till the execution is done? or what?

Its the same file to be executed in different timings.

I think i can do this with the cron tab, but i dont prefer that.

1
  • they will run at the same time. Commented Nov 26, 2012 at 17:21

2 Answers 2

2

They will have no problems running simultaneously but bear in mind you could have issues if they will be writing to the same file/database table.

Sign up to request clarification or add additional context in comments.

Comments

2

It will run the script twice, thrice or as many times it likes. If you only want to run this script one at a time, you can create a lock file and then check to see if it exists. Example:

if(file_exists('/tmp/script.lock')){ exit(); } file_put_contents('/tmp/script.lock',''); // execute code unlink('/tmp/script.lock'); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.