Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron syntax error near unexpected token

Moved the site to another server. Add file statistic.php to the Сron to perform. Only this Cron that does not like something. Write errors:

/home/site/www/statistic.php: line 1: ?php: No such file or directory
/home/site/www/statistic.php: line 2: syntax error near unexpected token `"bd.php"'
/home/site/www/statistic.php: line 2: `include ("bd.php");

There is my code

<?php
include ("bd.php");

    $result = mysql_query("SELECT MAX(id) FROM statistic_dep",$db);
    $myrow1 = mysql_fetch_array($result);
    $last_id=$myrow1[0];
...
like image 936
T_E_M_A Avatar asked Sep 28 '22 19:09

T_E_M_A


1 Answers

Make sure, that you execute the script as php script and not as bash script.

Your crontab should look like this:

* * * * * /usr/bin/php -f /path/to/file.php

Another way to execute the script as php is to add a shebang in the first line:

#!/usr/bin/php
<?php ...
like image 162
Dirk Avatar answered Oct 03 '22 02:10

Dirk