duanlu4371 2013-11-17 07:04
浏览 47
已采纳

使用cron job在localhost上运行php脚本

I am trying to set up a cron job on my localhost to call a php script every half an hour 24/7. Following are my steps:

1) I have created a cron.php file to call myscript.php:

<?php

echo exec('*/30 * * * * C:\BitNami\wampstack-5.4.21-0\php -f C:\BitNami\wampstack-5.4.21-0\apache2\htdocs\myscript.php');

?>

2) Created a cron.bat file to run the cron.php on browser:

"C:\Program Files\Mozilla Firefox\firefox.exe" "localhost\cron.php"

3) Then I have set up a windows 7 task scheduler to call cron.bat every day.

I welcome any idea on how to set up a cron job as my approach doesn't do anything.

Thanks

  • 写回答

3条回答 默认 最新

  • ds34222222 2013-11-17 07:13
    关注

    This is not an answer, but only pointers you need to check before you proceed further.

    1. Crons are available only on unix systems, not windows.

    2. While debugging cron or anything similar, schedule them for every minute or (any such acceptable smaller frequency), and once they work every minute, only then schedule them for the original frequencies. That will save you some time during debugging.

    3. Its an incorrect call to exec. You don't have to pass all those * in it

    4. Since this is windows, You want to do php.exe and not C:\BitNami\wampstack-5.4.21-0\php -f which would have been done in linux (with proper path)

    5. Your .bat file is currently scheduled daily, you need to schedule it every half hour.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料