title: Run a PHP script every second using CLI
body: <p>I have a dedicated server running Cent OS with a Parallel PLESK panel. I need to run a PHP script every second to update my database. These is no alternative way time-wise, it needs to be updated every second.</p>
  
  <p>I can find my script using the URL <code>http://www.somesite.com/phpfile.php?key=123</code>.</p>
  
  <p>Can the file be executed locally every second? Like <code>phpfile.php</code>?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>It has been a few months since I added this question. I ended up using the following code:</p>
  
  <pre><code>#!/user/bin/php
  &lt;?php
  $start = microtime(true);
  set_time_limit(60);
  for ($i = 0; $i &lt; 59; ++$i) {
      doMyThings();
      time_sleep_until($start + $i + 1);
  }
  ?&gt;
  </code></pre>
  
  <p>My cronjob is set to every minute. I have been running this for some time now in a test environment, and it has worked great. It is really super fast, and I see no increase in CPU nor Memory usage.</p>