I write programs to do calculations. In order to automate some things I setup my Mac to consume a queue of jobs and a cron will check the queue and then run them through.
I noticed that cron jobs run so much slower.
As root I am running all the commands at nice -n -100 (yes I know -20 is the limit)
if I run this command from the terminal it take 62 seconds. Checking the ps this is what I see:
UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME
0 17826 17195 4006 0 31 -20 413217088 581472 - R<+ 0 ttys000 16:11.07 /usr/local/bin/M 0.358 12:41PM
Now comparing that to the cron'd job this same calculations will take 441 seconds. The ps comes out to:
UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME
0 18231 18230 4004 0 20 -20 411514512 515632 - R< 0 ?? 28:16.72 /usr/local/bin/M 12:47PM
This is 7x slower!
Both processes are at -20 NICE, but the priority for the cron job is 20 while running from terminal is 31. So I am guessing that priority is the mitigating factor here.
I can't seem to figure out how to change the priority of the job. Lots resources out there just seem to think by changing nice you also change priority. But that is not the case.
The question I have is how do I change the priority of a cron job (or any job in fact).
I am running on a MacBook Pro (2013). I was thinking maybe Apple Mac Pro desktops could be setup differently but I just don't know.