Results 1 to 8 of 8

Thread: php failure: Text File Busy

  1. #1
    Join Date
    Aug 2010
    Location
    Hopewell Junction, NY
    Beans
    318
    Distro
    Ubuntu 16.04 Xenial Xerus

    php failure: Text File Busy

    In ubuntu 20.04, php 7.4, I have a php script in a remotely mounted directory (nfs). The server where the script resides is running php-7.4. On the server, the script runs until I open it for editing (and close it). Then forever after (it seems) the script fails with error: "/usr/bin/php: bad interpreter: Text file busy". The remote machine runs php-7.0, and the script runs under that whether or not it can run on the server. I checked lsof to see if the file is open and it's not listed.

    Apparently, the only way to reset this is to reboot the server.

  2. #2
    Join Date
    Aug 2017
    Beans
    103

    Re: php failure: Text File Busy

    This most likely means at the time you are calling the script, it is being executed. PHP files after all are plain text files. I doubt there's a "forever" especially since you get nothing with lsof. My first guess would be something in the timing of your logic occurs while the "editing" is happening.

    IMO I would try another way other than editing a running script. Move whatever you need to edit into a config file, edit that instead. If you absolutely must stick with this logic, open a copy, modify, resave, then rename. Even if you use a config file, operate on a copy and rename.

  3. #3
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    15,055
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: php failure: Text File Busy

    Make sure you have the opening and closing PHP tags in your script. It should look like this:
    Code:
    #!/usr/bin/php 
    <?php
    PHP code here
    ?>
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  4. #4
    Join Date
    Aug 2010
    Location
    Hopewell Junction, NY
    Beans
    318
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: php failure: Text File Busy

    This isn't something limited to php, it happens with bash scripts too. The good news is that it isn't "forever," it eventually clears.

  5. #5
    Join Date
    Aug 2017
    Beans
    103

    Re: php failure: Text File Busy

    Closing tags are only necessary for inline code, a bad practice IMO (violates separation of concerns) and not required if it's the last output in the file.
    Code:
    <?php
    echo "<p>This is some inlne PHP code.</p>";
    ?>
    
    <p>This is some regular text output.</p>
    
    <?php
    echo "<p>And we're done.</p>";

  6. #6
    Join Date
    Aug 2010
    Location
    Hopewell Junction, NY
    Beans
    318
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: php failure: Text File Busy

    Quote Originally Posted by sdsurfer View Post
    This most likely means at the time you are calling the script, it is being executed. PHP files after all are plain text files. I doubt there's a "forever" especially since you get nothing with lsof. My first guess would be something in the timing of your logic occurs while the "editing" is happening.

    IMO I would try another way other than editing a running script. Move whatever you need to edit into a config file, edit that instead. If you absolutely must stick with this logic, open a copy, modify, resave, then rename. Even if you use a config file, operate on a copy and rename.
    It just makes debugging scripts a little more complicated. It must be a "security" thing.

  7. #7
    Join Date
    Aug 2010
    Location
    Hopewell Junction, NY
    Beans
    318
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: php failure: Text File Busy

    Quote Originally Posted by sdsurfer View Post
    IMO I would try another way other than editing a running script. Move whatever you need to edit into a config file, edit that instead. If you absolutely must stick with this logic, open a copy, modify, resave, then rename. Even if you use a config file, operate on a copy and rename.
    This doesn't solve the problem. I copied a script, edited the copy, then renamed it to the original name, and when I tried to run the script, it failed with the "Text file busy" error message.

  8. #8
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    15,055
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: php failure: Text File Busy

    We need to see the script, inside [code][/code] tags.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •