cpulimit: detect failure / exit status in Linux
0
votes
1
answer
76
views
I'm using
cpulimit
in a Bash script to run a certain command (ffmpeg) with a limited CPU usage, but I want to know if the command fails. But when the command(ffmpeg) fails with any error, cpulimit still exists with exit status 0. What should I do?
My cpulimit command: cpulimit -l 300 -f -- ffmpeg ...
CPUlimit version 3.0
OS: Ubuntu with Linux 6.8.0
Note: cpulimit does not work on forks of the given command, unless I pass --monitor-forks flag, which the manual says is a bad idea specially in scripts:
> -m, --monitor-forks watch and throttle child processes of the target process Warning: It is usually a bad idea to use this flag,
> espe‐ cially on a shell script. The commands in the script will each
> spawn a process which will, in turn, spawn more copies of this program
> to throttle them, bogging down the system. Also, it is possible for a
> child process to die and for its PID to be assigned to another
> program. When this happens quickly it can cause cpulimit to target the
> new, unin‐ tended process before the old information has had a chance
> to be flushed out. Only use the monitor-forks option in specific
> cases, ideally on machines without a lot of new processes being
> spawned.
Asked by saeedgnu
(153 rep)
Feb 9, 2025, 07:04 AM
Last activity: Feb 9, 2025, 08:48 AM
Last activity: Feb 9, 2025, 08:48 AM