1

I'm running Uniform Server Zero XIV and am trying to use the cron to run a php script every 15 minutes. When ran manually, the script does what it is supposed to, which is updating values in a database. However, the cron never seems to actually execute the script.

The cron log is indicating that the crontab has the correct path and is executing.

10/06/2021 12:53:08  - Run OK --- C:\Users\myuser\Zero\UniServerZ\www\database\cronUpdate.php

The cron config is using absolute path.

[update]
start = 2021-05-14 8:00:00
period = 300
path = \www\database\cronUpdate.php
ref    = 1623329287

Here is the php file im trying to execute. Essentially it is pulling all the hostnames in the mysql database and sending them to an update function. The update function pulls API information about the units and updates the mysql database accordingly, with no return.

    include_once '../database/dbh.php';
    
    # Get all hostnames
    $sql = "SELECT hostname FROM units;";
        
    $result = mysqli_query($conn, $sql);
    
    
    while($row = mysqli_fetch_array($result)) {
                        
        # Add all units to formdata to be submitted
        $data['formData'][] = $row['hostname'];
                    
    }
    
    $fields = http_build_query($data);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://localhost/database/dbUpdate.php");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    $cResult = curl_exec($ch);
    
    curl_close($ch);

I've tried using a url in the config but that doesn't work either. I've also tried having the update file write to a log on execution and nothing ever gets written, which says to me that cron cannot execute this script. Any ideas on why the cron cannot execute this script? Would it be worth it to write this script in another language?

For the record the server is running php 8.0.3 and mysql 8.0.23

1 Answer 1

-2

Try changing the path to:

path = http://www/database/cronUpdate.php

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .