I have a directory, and want to operate
ffmpeg on each of the files.
My command is something like this:
$ find *|while read file; > do > ffmpeg -nostdin -i "$file" -vf "scale=iw/2:ih/2" "bak_$file" && mv -f "bak_$file" "$file" & > done
I want to run as many processes in the background as I can, but only if its taking at max 80% of free memory. If I just press enter, it causes my entire
ec2 instance to crash.
How can I limit the total amount of memory that is used? Let's say the first 4
ffmpeg already use 85%. Then I want to wait until we are less than 80%, and then run the other ones.
$ free -h total used free shared buff/cache available Mem: 978M 140M 136M 1.0M 701M 692M Swap: 0B 0B 0B