title: How to auto run a script every 30 min, store the output data on my server, and alert me about changes?
body: <p>I created a PHP script that checks the value of a <code>price</code> field from some API system.</p>
  
  <p>Now, I want my server to:</p>
  
  <ol>
  <li><p>Run this script automatically, every 30 minutes (should it be with Cron Jobs?)</p></li>
  <li><p>Store the data somewhere - Should it be in a database? I used the cPanel MYSQL wizard to create my first database, but have no idea how to continue from here.</p></li>
  <li><p>Send me an email alert whenever the price changes, compared to the previous recorded price value.</p></li>
  </ol>
  
  <p>Here is the script:</p>
  
  <pre><code>$myHeaders = array("key:  secretkey");
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, "https://api.com");
  curl_setopt($ch, CURLOPT_HTTPHEADER,$myHeaders);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  
  $returnResult = curl_exec($ch);
  
  // here the dom is generated
  $xml = simplexml_load_string($returnResult);
  
  echo $xml-&gt;products-&gt;product-&gt;price-&gt;__toString();
  
  //not sure what the rest of this code does:
  
  if ($returnResult) {
      //parse HTTP Body to determine result of request
      if (stripos($returnResult,"Error Code ")) {
          // error occurred
          trigger_error($returnResult,E_USER_ERROR);
      }
      else{
          // success
          //echo $returnResult;
      }
  }
  
  else{
      // connection error
      trigger_error(curl_error($ch),E_USER_ERROR);
  }
  
  curl_close($ch);
  </code></pre>
  
  <p>How can I accomplish all this?</p>