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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?