【问题标题】:at command for linux job not working from phpat linux 作业的命令不能从 php 工作
【发布时间】:2016-06-09 04:12:56
【问题描述】:

我有一个脚本.sh,其中有一个 命令:

curl --digest "http://xxxxxxx.xxx/mail.php?email=xxxx@xxx.xx";

从终端这很好用:

./script.sh #(mail arrives in my box)

从 php 这很好用:

shell_exec('./phpsc.sh');  // (mail arrives in my box) 

从终端这很好用:

 at -f phpsc.sh now + 5 minute 
 # (job created, mail arrives in my box after 5 minutes)

从 php 这将不起作用:

shell_exec('at -f phpsc.sh now + 5 minute'); //:( :(

即使我将at 命令放入脚本并从php 运行脚本at 命令,它也会被忽略:(

【问题讨论】:

  • phpsc.sh 和 script.sh 之间的区别尚不清楚 - 但可能从添加at -f _add_path_here_/phpsc.sh now + 5 minute的路径开始
  • 是的,我确实放了完整路径,但什么也没放 :( :(

标签: curl php linux shell at-job


【解决方案1】:

我找到了解决办法,

我从 /etc/at.deny 中删除了 www-data,现在 'at' 命令在 php (sell_exec) 中运行良好

【讨论】:

    【解决方案2】:

    我知道有时需要使用source 来调用环境变量。

    这里是你应该尝试的(如果你使用以外的其他东西,请适应):

    shell_exec('source ${HOME}/.kshrc ; at -f phpsc.sh now + 5 minute'); 
    

    【讨论】:

    • 对不起,但我不明白我必须做什么:( :(
    【解决方案3】:

    在 CentOS 7 中,我必须在 /etc/at.allow 中添加“apache”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-11
      • 1970-01-01
      • 1970-01-01
      • 2015-05-20
      相关资源
      最近更新 更多