0

This is the thing, i am preparing a webpage and i need that PHP holds a condition, if the condition is true, it execute some program with the function exec(), after that, (as it is automated) the webpage should refresh itself to keep looking the condition, if the condition is false, it should refresh after two seconds of waiting.

I was doing something with header("refresh:2;url=_url_here"); but its useless if the function exec() lasts longer than two seconds...

Thank you in advance for your help.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
user2905333
  • 35
  • 1
  • 5
  • This sounds like a Bad Idea. – Jonathon Reinhart Oct 22 '13 at 02:40
  • What you can do is check for the exec () pid id to see if it is still active.. if not then condition should be true/false what ever you want.. as far as the refresh.. I would setup a cronjob. I was going to say jquery but I wasnt sure since, what you are asking can be dangerous. – xlordt Oct 22 '13 at 02:49
  • I see, but, how you command to refresh your page after seeing that the exec()? After that i can easily setup a cronjob as you say :) – user2905333 Oct 22 '13 at 02:55
  • something like exec ("command > /dev/null 2>&1 & echo $!", $data); the rest is homework. also have crond update a file and you can check that file. – xlordt Oct 22 '13 at 03:15
  • Solved, thank you very much :) i'm new here, so, how do i mark as you answered my question? – user2905333 Oct 22 '13 at 03:24

1 Answers1

0

something like exec ("command > /dev/null 2>&1 & echo $!", $data); once that is done, check for pid id, if id exists, then the rest is homework. but best way is have cron update a file and you can check that file for any updates.

xlordt
  • 521
  • 4
  • 15