2014-11-05 22:59
浏览 63


I'm attempting to write an upgrade script for one of our website. Currently the script will unzip files provided from the upgrade link and unzip to the directory.

My problem is if there is a new version of itself i.e. upgrader-new.php I need the script to run to completion and then delete itself, then haveupgrader-new.php be renamed to upgrader.php.

The only solution I can think of would be to create a third file i.e. upgrade-assist.php that would be run before any upgrade to check if upgrader-new.php exists and if it does, delete the original and rename the new to the proper name. I forsee problems because the original script would still have to call upgrader-assist.php and as far as I know you can't delete a running script?

Any suggestions?


图片转代码服务由CSDN问答提供 功能建议

我正在尝试为我们的某个网站编写升级脚本。 目前,该脚本将解压缩从升级链接提供的文件并解压缩到该目录。

我的问题是,如果有自己的新版本,即 upgrader-new.php 我需要脚本运行完成然后删除自己,然后有 upgrader-new.php 重命名为 upgrader.php

我能想到的唯一解决方案是创建第三个文件,即 upgrade-assist.php ,它将在任何升级之前运行,以检查是否 upgrader-new.php 存在,如果存在,删除原始文件并将新名称重命名为正确名称。 我预见到问题,因为原始脚本仍然需要调用 upgrader-assist.php ,据我所知你不能删除正在运行的脚本?



  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dony39517 2014-11-05 23:05

    as far as I know you can't delete a running script?

    You can, try this one:

    <?php unlink(__FILE__);

    It is perfectly fine, unless there are other processes using this file (and of course running process has enough permission to do so).

    File is not processed and executed line by line, but loaded into memory so you can freely rename or delete it, and it will still run until the end (or fatal error).

    解决 无用
    打赏 举报

相关推荐 更多相似问题