cron job做定时有没有谁会的,教一下,网上教程看不懂

@Ta 2013-01-13 13557点击
是不是必须得写一个shell脚本,shell脚本里包含执行php脚本的指令??cp控制面板里的cron job是不是只能执行shell脚本不能直接执行php
无敌召唤@老虎会游泳 @浪人 @小男生 @淡然 @郑锋 
回复列表(28|隐藏机器人聊天)
  • @Ta / 2013-01-13 / /
    好像是
  • @Ta / 2013-01-13 / /
    不会= =
  • @Ta / 2013-01-13 / /
     @15835038549 表示不会
  • @Ta / 2013-01-13 / /
    那shell具体怎么写啊@趣航科技小智
  • @Ta / 2013-01-13 / /
    百度
  • @Ta / 2013-01-13 / /
    可以直接php,不过文件里面的路径要用绝对路径
  • @Ta / 2013-01-13 / /
  • @Ta / 2013-01-13 / /
    <?php
    ini_set("max_execution_time","500");
    date_default_timezone_set("PRC");
    $time=date("H",time());
    if(($time>5)&&($time<20)){
    if(!file_exists('jy.txt')){
    $result=file_get_contents('http://www.kgda.tk/fx/cl.php');
    echo $result;
    if(preg_match('/发送成功/',$result))
    file_put_contents('jy.txt',$result);
    }
    if(!file_exists('jy2.txt')){
    $result=file_get_contents('http://www.kgda.tk/fx/tq.php');
    if(preg_match('/发送成功/',$result))
    file_put_contents('jy2.txt',$result);
    }
    }
    else if($time>=20){
    if(file_exists('jy.txt')){
    unlink('jy.txt');
    }
    if(file_exists('jy2.txt')){
    unlink('jy2.txt');
    }
    }


    ?>
    可是file_get_contents也不执行。。@-名 
    顺便问下,绝对路径怎么写
  • @Ta / 2013-01-13 / /
    我的挂Q就是用控制面板里面的cron job监控的
  • @Ta / 2013-01-13 / /
    @-名 你用的是yh空间吗??
  • @Ta / 2013-01-13 / /
    比如把jy.txt写成/home/..../public_html/jy.txt
  • @Ta / 2013-01-13 / /
  • @Ta / 2013-01-13 / /
    如果没有执行的话就是你在cp后台没有设置好
  • @Ta / 2013-01-13 / /
  • @Ta / 2013-01-13 / /
    @-名 这个五分钟执行一次对不对*/5 * * * * php -f /home/u540858235/public_html/fx/ds.php
  • @Ta / 2013-01-13 / /
    ds.php

    <?php
    ini_set("max_execution_time","500");
    date_default_timezone_set("PRC");
    $time=date("H",time());
    if(($time>5)&&($time<20)){
    if(!file_exists('/home/u540858235/public_html/fx/jy.txt')){
    $result=file_get_contents('http://www.kgda.tk/fx/cl.php');
    echo $result;
    if(preg_match('/发送成功/',$result))
    file_put_contents('/home/u540858235/public_html/fx/jy.txt',$result);
    }
    if(!file_exists('jy2.txt')){
    $result=file_get_contents('http://www.kgda.tk/fx/tq.php');
    if(preg_match('/发送成功/',$result))
    file_put_contents('/home/u540858235/public_html/fx/jy2.txt',$result);
    }
    }
    else if($time>=20){
    if(file_exists('/home/u540858235/public_html/fx/jy.txt')){
    unlink('/home/u540858235/public_html/fx/jy.txt');
    }
    if(file_exists('/home/u540858235/public_html/fx/jy2.txt')){
    unlink('/home/u540858235/public_html/fx/jy2.txt');
    }
    }


    ?>
  • @Ta / 2013-01-13 / /
    @-名 成功执行 万分感谢
  • @Ta / 2013-01-13 / /
  • @Ta / 2013-01-13 / /
    @-名 cron中条件结构,注释全部无效??
添加新回复
回复需要登录