zoukankan      html  css  js  c++  java
  • 执行 crontab 的计划任务

    新建了一个 Laravel 的计划任务,配置好 crontab

    * * * * * php /www/sunzhongwei/artisan schedule:run >> /dev/null 2>&1
    

    同时,将当前登录用户,添加到了 www-data 的用户组,以防止无法访问 storage/logs 下的日志文件。

    但是,执行了一段时间,导致 web 请求报错

    file_put_contents(/www/sunzhongwei/storage/framework/cache/data/f1/6c/f16xxxx56b65501434d05bf1fc20c9fc8f9): failed to open stream: No such file or directo
    ry
    

    通过 ls -la 查看,可以发现该文件属于当前登录用户,而不是 www-data,用户组也不是 www-data 所属的用户组。

    那就说明解决方法只有一个,就是以 www-data 的身份执行 laravel crontab 的计划任务。

    对应的命令是

    sudo crontab -u www-data -e
    

    然后把上面的计划任务配置剪切过来就可以了。

    测试环境

    Ubuntu 16.04 Server

    参考

    https://askubuntu.com/questions/189189/how-to-run-crontab-as-userwww-data

  • 相关阅读:
    source insight 使用介绍
    android 自定义progressBar
    appium环境安装
    js定义类的三种方法
    对象,函数,构造函数this,原型
    mindjet使用技巧
    在wamp下安装bugfree
    QTP
    powerdesigner使用
    随笔
  • 原文地址:https://www.cnblogs.com/sgm4231/p/10196240.html
Copyright © 2011-2022 走看看