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条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记