• file occupied

    From zeneca@3:770/3 to All on Tuesday, July 05, 2022 09:52:24
    I wrote a program run every 5 minutes from a bash script.
    It run ok, but when I reboot it doesn't start giving :

    -bash: ./nokia: Fichier texte occupé
    ( text file occupied )
    ??
    I can't run it manually, same error.
    to solve this I have to recompile no changes in source code ( C)
    any idea ?
    Many thanks

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Josef Moellers@3:770/3 to zeneca on Tuesday, July 05, 2022 10:03:03
    On 05.07.22 09:52, zeneca wrote:
    I wrote a program run every 5 minutes from a bash script.
    It run ok, but when I reboot it doesn't start giving :

    -bash: ./nokia: Fichier texte occupé
    ( text file occupied )
    ??
    I can't run it manually, same error.
    to solve this I have to recompile no changes in source code ( C)
    any idea ?
    Many thanks

    If you can reproduce, run the program with "strace":
    strace -fo nokia.out ./nokia
    and then search the file "nokia.out" for "ETXTBSY".

    The error itself means that the program tries to open some executable
    file (or a shared object) for writing but that file is currently in use.

    Josef

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to zeneca on Tuesday, July 05, 2022 11:33:52
    On Tue, 5 Jul 2022 09:52:24 +0200, zeneca wrote:

    I wrote a program run every 5 minutes from a bash script.
    It run ok, but when I reboot it doesn't start giving :

    -bash: ./nokia: Fichier texte occupé ( text file occupied )
    ??
    I can't run it manually, same error.
    to solve this I have to recompile no changes in source code ( C)
    any idea ?

    Are you sure your script or compiled program isn't attempting to overwrite
    the compiled binary?

    lsof may show you what's going on:

    "lsof -- ./nokia | less" - piping lsof through less is a good idea because
    lsof can produce a lot of output.


    --

    Martin | martin at
    Gregorie | gregorie dot org

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Martin Gregorie@3:770/3 to zeneca on Tuesday, July 05, 2022 11:21:39
    On Tue, 5 Jul 2022 09:52:24 +0200, zeneca wrote:

    I wrote a program run every 5 minutes from a bash script.
    It run ok, but when I reboot it doesn't start giving :

    -bash: ./nokia: Fichier texte occupé ( text file occupied )
    ??
    I can't run it manually, same error.
    to solve this I have to recompile no changes in source code ( C)
    any idea ?
    Many thanks

    How is the wait handled? If you're running something like

    stop = 0
    while (stop)
    do
    nokia
    sleep 5m
    done

    consider rewriting it as a cron script instead As an example, my internet connection is slow often enough that I check its speed every 10 minutes
    with this cron script in /etc/cron.d


    #
    # Run at 15 minute intervals
    # ==========================
    # Results are sent to root
    #
    MAILTO=root

    2,17,32,47 0-23 * * * root /usr/local/bin/adslchk -b 2>&1 >>/var/log/
    adslchk


    This cron script runs the "/usr/local/bin/adslchk -b 2>&1 >>/var/log/
    adslchk" command at 2,17,32,47 minutes after each hour and writes the
    script output to /var/log/adslchk.

    The advantages of this approach are that:
    - the process is automatically started when the computer is rebooted
    - the adslchk script only runs for a few seconds each time its started



    --

    Martin | martin at
    Gregorie | gregorie dot org

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)