1
Write a post

Use less CPU for Rails

Published Jul 13, 2017

Is Rails eating your CPU in development? Try lowering its priority using renice(1), a standard BSD utility that should be available in OS X and most Linux distributions. Here’s a shell script that will automatically reset the priority to +15 to common development processes:

#!/usr/bin/env sh
sudo renice +15 -p $(ps ax | grep -E 'ruby|node|watchman|postgres' | grep -v grep | awk '{print $1}' | tr '\n' ' ')
Save this as renice-dev into one of your bin paths, and give it a chmod +x renice-dev. You can type renice-dev after you start your development processes to “renice” them.

The lowest priority is +19 (only run when nothing else is running), the default is 0, and the highest is -20 (makes things go very fast).

Discover and read more posts from Rico Sta. Cruz
get started
Enjoy this post?

Leave a like and comment for Rico

Be the first to share your opinion

Subscribe to our weekly newsletter