php - Cron job report error -



php - Cron job report error -

i got cron job next code:

<?php require "config.php"; $truncate = $mysqli->query("truncate rss_feed"); $cars = $mysqli->query("select *,(select title companies companies.company_id = cars.company_id) car_company,(select car_model models models.model_id = cars.model_id) car_model cars, companies cars.company_id = companies.company_id , car_active = 'active' , rsspost null order datetime desc"); $result = $cars->num_rows; if ($result > 0) { while ($row_cars = $cars->fetch_array()) { $title = $row_cars['car_company'] . ' ' . $row_cars['car_model'] . ' ' . $row_cars['car_cc']; $link = '/car.php?id=' . $row_cars['car_id']; $description = $row_cars['car_description']; $datetime = $row_cars['datetime']; $row_car_id = $row_cars['car_id']; $insert = $mysqli->query("insert rss_feed (title, link, description, datetime) values ('$title','$link','$description','$datetime')"); $update = $mysqli->query("update cars set rsspost='yes' car_id = '$row_car_id'"); if (!$insert) { printf("error: %s\n", $mysqli->error); } } printf($result . " cars inserted"); } else { printf("no new cars inserted"); }

i've set cpanel run php file every 3 hours , got error below:

/public_html/system/cron_rss.php: line 1: ?php: no such file or directory /public_html/system/cron_rss.php: line 2: require: command not found /public_html/system/cron_rss.php: line 3: syntax error near unexpected token `(' /public_html/system/cron_rss.php: line 3: `$truncate = $mysqli->query("truncate rss_feed");'

if run file through url, works ok without errors. ide editor confirms there no suspicious code. got 755 chmod file.

from first error line seems not calling script cron.

depending on host , possibilities may seek 1 of these:

specify cron entry way:

* * * * * /usr/bin/php <path_to_your_script>

or specify cron entry way:

php -q <path_to_your_script>

or can seek write in first line of script:

#!/usr/bin/php

you can check if this give-and-take help:

discussion

php cron

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -