Title: Run PHP script doesn&#8217;t work
Last modified: April 19, 2017

---

# Run PHP script doesn’t work

 *  [Hkroed](https://wordpress.org/support/users/sprithansi/)
 * (@sprithansi)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/run-php-script-doesnt-work/)
 * Hi!
    I’m trying to set up a fixed interval schedule to run a PHP script, but 
   it doesn’t run. The “Nest run”-time doesn’t update either.
 * I have the following setup
    Run every 10 minutes Action: Run PHP-script Custom
   action: None Argument (optional): None PHP script path: URL to the php-file with
   the script
 * Here is the scrpt inside the PHP-file
 *     ```
       <?php
       //set the connection variables
       $hostname = "";
       $username = "";
       $password = "";
       $database = "";
       $filename = "";
   
       //connect to mysql database
       $connection = mysqli_connect($hostname, $username, $password, $database) or die("Error " . mysqli_error($connection));
   
       mysqli_query($connection, "TRUNCATE TABLE <code>Pristabell</code>");
   
       // open the csv file
       $fp = fopen($filename,"r");
   
       //parse the csv file row by row
       while(($row = fgetcsv($fp,"500",",")) != FALSE)
       {
           //insert csv data into mysql table
           $sql = "INSERT INTO Pristabell (Produkt, Pris, Rabattkr, Rabattprosent, Lagerstatus, Butikk, TAGS) VALUES('" . implode("','",$row) . "')";
           if(!mysqli_query($connection, $sql))
           {
               die('Error : ' . mysqli_error($connection));
           }
       }
       fclose($fp);
   
       //close the db connection
       mysqli_close($connection);
   
       ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [miunosoft](https://wordpress.org/support/users/miunosoft/)
 * (@miunosoft)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/run-php-script-doesnt-work/#post-9047460)
 * Hi,
 * > PHP script path: URL to the php-file with the script
 * It should not be a URL but a path. You should set it with the file selector which
   pops up when you click on the folder icon next to the input field.
 *  Thread Starter [Hkroed](https://wordpress.org/support/users/sprithansi/)
 * (@sprithansi)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/run-php-script-doesnt-work/#post-9049432)
 * Tested, but it still not running.
    See the attached image. Next run was 15 hours
   ago…
 * [Image](http://tunebrygget.no/prisminister/wp-content/uploads/csvimport/taskscheduler.jpg)
    -  This reply was modified 9 years, 1 month ago by [Hkroed](https://wordpress.org/support/users/sprithansi/).
 *  Plugin Author [miunosoft](https://wordpress.org/support/users/miunosoft/)
 * (@miunosoft)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/run-php-script-doesnt-work/#post-9049703)
 * You can check whether the server heartbeat is running by going to Dashboard -
   > Task Scheduler -> Settings -> Server Heartbeat. Make sure it is on. And see
   if the time is constantly updated in the Status field as you reload the page 
   in one minute.
 * If the server heartbeat is not running, scheduled tasks will not get triggered.
 *  Thread Starter [Hkroed](https://wordpress.org/support/users/sprithansi/)
 * (@sprithansi)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/run-php-script-doesnt-work/#post-9050276)
 * I found the problem.
    When I deactivated WP Maintenance Mode plugin, its working
   [https://nb.wordpress.org/plugins/wp-maintenance-mode/](https://nb.wordpress.org/plugins/wp-maintenance-mode/)
 * Don’t know why, but maybe you do 🙂
 * Thanks anyway for a great plugin (Y)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Run PHP script doesn’t work’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/task-scheduler_ffffff.svg)
 * [Task Scheduler](https://wordpress.org/plugins/task-scheduler/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/task-scheduler/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/task-scheduler/)
 * [Active Topics](https://wordpress.org/support/plugin/task-scheduler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/task-scheduler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/task-scheduler/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [script](https://wordpress.org/support/topic-tag/script/)

 * 4 replies
 * 2 participants
 * Last reply from: [Hkroed](https://wordpress.org/support/users/sprithansi/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/run-php-script-doesnt-work/#post-9050276)
 * Status: not resolved