开发者

Unix `at` command via 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 ss开发者_如何学Pythonh everything works as expected.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜