Have a file File.txt and if any process is trying to copy the file from /source/ to /destination/

Is there a way to identify if the file File.txt (or any other file ) available in /destination/ is completely copied, or the process is still going on.

I tried lsof but its not working

**Error** : lsof: WARNING: can't stat() nfs file system

Any suggestions

  • install progress and run progress -m and it should be able to tell you. If your command is not a well-known command run progress -m -c my_command. Or install pv, which also works but it requires the PID to be supplied, as in pv -d 1234.
    – user339730
    Nov 10, 2020 at 9:05

1 Answer 1


Try to use rsync with --progress option next time.

Here is a little snippet that will help you to get the progress status every second until it reaches 100% percent ; Just replace your source and destination file paths.

n="$(du -sh <path_to_your_source_file> | awk '{print $1}' | sed 's/[^0-9.]*//g')"
while true; do sourcesize="$n" destdir=<path_to_your_dest_file> copyprogress="$(export | du -sh $destdir | awk '{print $1}' | sed 's/[^0-9.]*//g' )" ; echo "scale=3 ; $copyprogress / $sourcesize * 100" | bc | xargs echo -n ; echo % completed ; sleep 1 ; done

enter image description here

Also you can check whether cp command is still running by using pidof and use ps to check the full command that is being executed:

enter image description here

  • It's an output instead of code, how could i avoid it ?
    – Reda Salih
    Nov 6, 2020 at 21:08
  • Just copy-paste it directly from your terminal emulator! Nov 6, 2020 at 23:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.