I am running a CLI script that is basically sleeping. Every 10 seconds or so, the script executes something. The problem is that the script sits at 94% of the CPU during sleep.
How I installed it:
while(1){
sleep(10);
doStuff();
}
Although this works as intended, there is an obvious problem. In C ++ / Java, I could just set a timer that will fix the loop problem. Also, I was hoping that I would not need cron jobs.
Is there an alternative way to do this?
Update
Apparently, my original script (which was rather large) never went into sleep mode, so the while loop executed single and burned CPU cycles. For those who have the same problem, make sure it is not!
source
share