Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Limit the cpu usage of a process

Terminal - Limit the cpu usage of a process
prlimit --cpu=10 sort -u hugefile
2013-02-27 15:59:11
User: mhs
Functions: sort
4
Limit the cpu usage of a process

Similar to `cpulimit`, although `prlimit` can be found shipped with recent util-linux.

Example: limit CPU consumption to 10% for a math problem which ordinarily takes up 100% CPU:

Before:

bc -l <(echo "1234123412341234^12341234")

See the difference `prlimit` makes:

prlimit --cpu=10 bc -l <(echo "1234123412341234^12341234")

To actually monitor the CPU usage, use `top`, `sar`, etc.. or:

pidstat -C 'bc' -hur -p ALL 1

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
sudo cpulimit -p pid -l 50
2011-11-21 08:43:57
User: Dhinesh
Functions: sudo
Tags: cpu
20

This will limit the average amount of CPU it consumes.

sudo cpulimit -e Grooveshark -l 20
2010-11-15 16:58:50
User: poulter7
Functions: sudo
0

Will limit the amount of CPU time Grooveshark the greedy yet useful Adobe Air app will have.

Leaves the UI lagging a little, but crucially does not ruin the audio.

Know a better way?

If you can do better, submit your command here.

What others think

Welcome to my Taobao shop !

Daily update:

Discover amazing stuff, collect the things you love, buy it all in one place.

novel style, varieties, low price and good quality, and the low sale price

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

New to Hong Kong : Winter Dress

Best quality, Best reputation , Best services

---**** NHL Jersey Woman $ 40 ---**** NFL Jersey $ 35

---**** NBA Jersey $ 34 ---**** MLB Jersey $ 35

---**** Jordan Six Ring_m $ 36 ---**** Air Yeezy_m $ 45

---**** T-Shirt_m $ 25 ---**** Jacket_m $ 36

---**** Hoody_m $ 50 ---**** Manicure Set $ 20

---**** handbag $ 37 ---**** ugg boot $ 43 ---****

give you the unexpected harvest

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

Comment by yeiuoisdf 84 weeks and 6 days ago

And what does it mean to limit the cpu time to 10 seconds: That the process can only run for maximal 10 CPU seconds? Or that the process will get re-scheduled after 10 seconds?

Comment by Flow 83 weeks and 4 days ago

Not seconds of time, but *CPU time* (as in "timesharing"). The CPU is a finite resource which has to be shared, and sometimes the greedy processes should be throttled; the other processes need their fair share of time on the CPU too.. So rather than allowing our greedy process to hog the CPU core for 100% of the time, we limit him to only 10% of the available time on that core.

Comment by mhs 83 weeks and 4 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts