dongyangben6144 2018-12-14 20:45
浏览 146

如何通过终端在localhost上执行php文件的cronjob

I'm trying to do a cronjob via terminal to run a php file every minute.

I added this line in my crontab list ...

* * * * * /usr/bin/php /Applications/XAMPP/xamppfiles/htdocs/stc/testcron.php

but the file does not execute, I wonder if my way is wrong ? or I didn't get the idea of it clearly ..

update :

I'm expecting this file to add a new record in my database...

when I use the line in the above , it didn't work

but when I enter it in this way

* * * * * /usr/bin/curl —silent—compressed http://localhost/stc/testcron.php

it worked !! I don't Know if this way is correct , and what the problem of the first one.

testcron.php content

<?php

include('config/con_db.php');
$conn = db_connect();

$conn->query("INSERT INTO `locations`(`location_name`, `location_lat`, `location_long`) VALUES ('Dammam',4.4,5.5);");

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据