Score:1

How to end a cpulimit on a process

im flag

I am utilising the very handy tool CPULimit to restrict the CPU usage of an import triggered in the cron of my Ubuntu server.

Successfully limiting the process is not a problem, I am also able to return the value back to no limit (100%) when the process ends, however when the import process terminates, I am left with CPULimit processes running. The list of CPULimit processes then gets appended to when the next cron job runs.

I can run a command like pkill -f cpulimit to remove the processes, however I am assuming there is a command that will terminate the limit, it just isn't documented.

To try help you understand here is a bit of a flow:

  1. Cron triggers import.
  2. Import script sets a cpulimit and points to > /dev/null: sudo -u {USER} cpulimit --pid {PID} --limit {LIMIT} > /dev/null &.
  3. A CPULimit process is added to the processes list when grep'ing ps aux | grep cpulimit.
  4. The import completes.
  5. The import script then returns the limit to 100%.
  6. A CPULimit process is added to the process list allowing 100% CPU.

~ This is what I thought would end the previous process, but it keeps the {LIMIT} processes running and the limit:100 process.

  1. The importer runs again.
  2. Two more CPULimit processes are added to the list in ps aux | grep cpulimit.

I can shell_exec(pkill -f cpulimit) which kills all the CPULimit processes other than the latest ones.

However, say I want to limit other processes and the timings don't work out perfectly, the limit on other restricted processes will also be killed.

Is there a way to initiate the cronjob, without freezing the importer when the CPULimit is applied (I got around this problem by sending it to > /dev/null), then when the importer ends, remove / delete / kill the limiter in this instance, as they currently just stack up?

** I am not requesting to kill the importer process if the limit is reached, I want to kill the CPULimit from the processes and remove the limit on the process it is limiting **

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.