file occupied

Jul 05, 2022 Last reply: 4 years ago 3 Replies

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

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

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.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required