开发者社区 问答 正文

关于linux下的shell变量

1.php代码,无任何参数。

public function clearHistoryLogAction(){
        $accountService = $this->getServiceLocator()->get("accountService");
        $now = date("y-m-d h:i:s",time());//当前时间
        $date = common::getPurMonth($now);
        $firstDate = $date[0].' 00:00:00';
        $endDate = $date[1].' 23:59:59';
        $sql = "delete from ".DB_FIX."log where ctime BETWEEN '$firstDate' and '$endDate'";
        $accountService->execute($sql);
        echo '1';
        die();
}

现在默认的是清除上个月的日志。 

2.shell定时计划

crontab -e -u root

*/1 * * * * curl http://xxx/clearLog  #这个是每秒运行一下clearLog页面,即清除上月日志。

现在的难点是,客户需要在服务器后台页面管理上添加2个参数,1.什么时间清除  2.清除哪个时间段日志

我shell都是写死的...怎么能通过变量传递到定时计划中,设置定时呢?

展开
收起
a123456678 2016-06-13 15:59:03 2180 分享 版权
1 条回答
写回答
取消 提交回答
  • 这个东西也好办啊,写个shell专门重置这个crontab,用户提交新设置的时候,就执行一下

    或干脆不用cron,用at

    2019-07-17 19:36:17
    赞同 展开评论