Ted
Ted

Reputation: 3885

Changing server behaviour periodically

I have a common settings file shared between PHP and my client's javascript to read from. My server is using another (external) server [that is down quite often] for a specific validation. The common settings file is specifying whether that validation should be carried out or not.

I would like my server to change the common settings file to not to check upon server down for about 30 minutes and then change the setting back again (the setting is "0"/"1").

I thought I should write a script that is run upon first occasion of server down.The script would go ahead and look something like that:

change_settings_file("DO_VALIDATION",0); 
sleep(30*60);
change_settings_file("DO_VALIDATION",1); 

so:

  1. Is this approach reasonable? any other thought maybe ?
  2. What would be the best approach to change a file's single character ? Should I read it entirely,change and write back down ? or is there another way to do that ?

Thanks!

Upvotes: 0

Views: 46

Answers (1)

adrien
adrien

Reputation: 4439

Quite strange to have a server down for so long and so often :/

Anyway, easiest way to do this is to use file_get_contents() and file_put_contents() PHP functions

Upvotes: 1

Related Questions