dst2017 2011-09-13 16:03
浏览 62
已采纳

Unix`at`命令通过PHP

Here's my code to create a new at job...
system('echo \'php -f /path/to/my/php/file.php\' | at 1700');

I thought this would be simple and would just work but alas, nothing happens!

When I run echo \'php -f /path/to/my/php/file.php\' | at 1700 via ssh everything works as expected.

Is this a permissions problem? I.e PHP isn't allowed to create new at jobs?

  • 写回答

1条回答 默认 最新

  • duane9322 2011-09-13 16:13
    关注

    Just FYI you have to make sure that you are allowed to execute system commands from your PHP scripts.

    A lot of servers have this feature disabled.

    However, if you want to turn this back on I believe you can do so in the php.ini file, you would have to turn safe_mode to off.

    When allowing user-supplied data to be passed to this function, use escapeshellarg() or escapeshellcmd() to ensure that users cannot trick the system into executing arbitrary commands.

    If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

    Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)