2

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.

3 Answers 3

8

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.

5
  • 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.
    – CK.
    Dec 7, 2009 at 13:23
  • 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.
    – wzzrd
    Dec 7, 2009 at 13:57
  • :) Any thoughts on an edit - it looks pretty clear to me.
    – CK.
    Dec 7, 2009 at 14:56
  • Edited to include known working versions of Ubuntu.
    – CK.
    Dec 7, 2009 at 15:06
  • Here's your point back :-)
    – wzzrd
    Dec 7, 2009 at 15:15
1

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.

2
  • 1
    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). Dec 7, 2009 at 12:59
  • @Kyle: +1 Good point, will do a little edit.
    – wzzrd
    Dec 7, 2009 at 13:04
1

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.

1
  • 1
    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.
    – wzzrd
    Dec 7, 2009 at 14:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .