I left my laptop cable at home, and I'm running on battery. I'm using Ubuntu Linux 9.10. I know about powertop
and I'm using that. It told me that a few things I'd installed (postgres, mysql, etc) were running, so I stopped them.
However is there a command that'll tell me all the things from /etc/init.d/
that are running? I can then decide to stop some of them.
-
One would hope so, but I know of no tool that does this. The problem mainly lies in the fact that - at least on Ubuntu - a lot of initscripts do not have a 'status' command. So, running a snippet like this
for service in /etc/init.d/*; do "${service}" status done
will not work, because you will be spammed with error-messages ad nauseam, telling you the status command does not work for a particular service.
You could do something similar with pgrep, but you would need to script a little something and know the names of the actual processes that are started by the init scripts.
Kyle Brandt : Matters less here, but I think for service in /etc/init.d/*; do "${service}" ... would be better. Eliminates the need for call to ls, and is safe for file names with spaces in them (although, /etc/init.d is not likely to have something with a space in it).wzzrd : @Kyle: +1 Good point, will do a little edit.From wzzrd -
On Ubuntu 9.04/9.10:
sudo service --status-all
For everything that responds to 'status' you'll get a +/- flag, and ? if they don't.
edit You can also install 'chkconfig' to see what is set to start in the various run levels.
CK : That's why I said to install chkconfig! Because I run a variety of differeny *ixs at home and work, I checked --status-all on a 9.04 Ubuntu before I posted. Obviously, it could have been removed in 9.10, but it seemed unlikely.wzzrd : Right. Apparently my version of Ubuntu here is too old and doesn't do status-all. If new ones do, I should shut the hell up ;-). Do a minor edit to your answer, so I can revoke my downvote.CK : :) Any thoughts on an edit - it looks pretty clear to me.CK : Edited to include known working versions of Ubuntu.wzzrd : Here's your point back :-)From CK -
The best way to see what is actually running is to run 'top'. Pressing 'm' will sort processes by memory usage. Note that the 'vmsize' column is usually overstated by about 90Mb.
wzzrd : You don't want to look at vmsize. You want to look at RES or RSS (depends on version of top). The resident set size shows the amount of actual physical RAM a program uses, which is a lot more interesting than the VMSIZE. And even then, the value of knowing a program's RSS is debated (Google it). Anyway, in this case, I'd use ps, not top. Top rarely has enough room to show all processes.From pjc50
0 comments:
Post a Comment