Cron语法错误接近意外令牌。

时间:2021-12-20 01:05:40

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:

将站点移动到另一个服务器。添加文件的统计。phpСron执行。只有这个不喜欢的Cron。写错误:

/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];
...

1 个解决方案

#1


3  

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

确保您执行的脚本是php脚本,而不是bash脚本。

Your crontab should look like this:

你的crontab应该是这样的:

* * * * * /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:

另一种执行php脚本的方法是在第一行中添加一个shebang:

#!/usr/bin/php
<?php ...

#1


3  

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

确保您执行的脚本是php脚本,而不是bash脚本。

Your crontab should look like this:

你的crontab应该是这样的:

* * * * * /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:

另一种执行php脚本的方法是在第一行中添加一个shebang:

#!/usr/bin/php
<?php ...