You are not logged in.

#1 2009-03-17 15:46:42

cwall64
Member
Registered: 2007-06-22
Posts: 5

list running daemons - is there a rc-status like Gentoo? [SOLVED]

Hi,
Sorry for the question, tried searching Wiki and Forums.  I am looking for a command like Gentoo has (rc-status) that will list all the running daemons with their status?

Last edited by cwall64 (2009-03-19 14:11:21)

Offline

#2 2009-03-17 16:18:08

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

I did this a long long time ago for someone on irc.  Never touched or looked at it since so it may need some work. http://rafb.net/p/pCKsob75.html


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#3 2009-03-17 17:20:25

cwall64
Member
Registered: 2007-06-22
Posts: 5

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

thanks!  I really appreciate it, after reading the script I feel a little foolish!

Offline

#4 2009-03-19 02:18:30

p0ft
Member
From: Brazil
Registered: 2009-02-02
Posts: 8

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

rson451 wrote:

I did this a long long time ago for someone on irc.  Never touched or looked at it since so it may need some work. http://rafb.net/p/pCKsob75.html

could you reupload it? I want this as well.

Last edited by p0ft (2009-03-19 02:18:55)


:: i wanna see movies of my dreams

Offline

#5 2009-03-19 10:47:56

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

#!/bin/bash
# daemon status

function chk_status()
{
  target=$1
  if [ $target != "functions" ] && [ $target !=  "functions.d" ]
  then
    if [ -f "/var/run/daemons/$target" ]
    then
      stat="[RUNNING]"
    else
      stat="[STOPPED]"
    fi

    printf "%-20s%-10s\n" $target $stat
  fi
}

daemons=$(ls /etc/rc.d/)

if [[ $1 != "" ]]
then
  chk_status $1
else
  for d in $daemons
  do
    chk_status $d
  done
fi

As I said before, I don't use this and it was done very quickly, so there is much room for improvement.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#6 2009-03-19 12:10:38

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

[stijn@hermes ~]$ ls /var/run/daemons/
acpid  alsa  bluetooth  cpufreqd  crond  cups  dbus  hal  mpd  net-profiles  ntpd  syslog-ng

Not sure that's everything you are looking for, but I'm sure it's something...


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#7 2009-03-19 13:55:15

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,422
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

modified rson's script for readability, basically just added color coding to the status messages.

#!/bin/bash
# daemon status

function chk_status()
{
  target=$1
  if [ $target != "functions" ] && [ $target !=  "functions.d" ]
  then
    if [ -f "/var/run/daemons/$target" ]
    then
      stat="\e[1;32m[RUNNING]"
    else
      stat="\e[1;31m[STOPPED]"
    fi

    echo -e "\e[1;37m$target $stat"
  fi
}

daemons=$(ls /etc/rc.d/)

if [[ $1 != "" ]]
then
  chk_status $1
else
  for d in $daemons
  do
    chk_status $d
  done
fi

Last edited by Ghost1227 (2009-03-19 13:55:39)


.:[My Blog] || [My GitHub]:.

Offline

#8 2009-03-19 17:36:28

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

nice!

big_smile

added sorting (the running daemons appear in the tail) and adjusted a little bit the printing format.
to the Ghost1227 version of rson's script

#!/bin/bash
# daemon status

 function chk_status(){
  target=$1
  if [ $target != "functions" ] && [ $target !=  "functions.d" ]
  then
    if [ -f "/var/run/daemons/$target" ]
     then
       stat="\e[1;32m[RUNNING]"
     else
       stat="\e[1;31m[STOPPED]"
     fi

    printf "$stat \t\e[1;34m$target\e[0;0m\n"
  fi
 }

 daemons=$(ls /etc/rc.d/)

 if [[ $1 != "" ]]
  then
   chk_status $1
 else
   for d in $daemons
    do
     chk_status $d
   done | sort
 fi

 exit 0

Last edited by quarkup (2009-03-20 20:56:47)


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#9 2009-03-19 21:28:01

toxygen
Member
Registered: 2008-08-22
Posts: 713

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

I <3 you guys


"I know what you're thinking, 'cause right now I'm thinking the same thing. Actually, I've been thinking it ever since I got here:
Why oh why didn't I take the BLUE pill?"

Offline

#10 2009-03-20 20:33:28

syntaxerrormmm
Member
From: Italy
Registered: 2008-10-22
Posts: 80
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

quarkup wrote:
...
tmpfile=/tmp/.dsort.tmp~

Why wasting time in I/O on the disk?

#!/bin/bash
# daemon status

function chk_status(){
 target=$1
 if [ $target != "functions" ] && [ $target !=  "functions.d" ]
 then
   if [ -f "/var/run/daemons/$target" ]
    then
      stat="\e[1;32m[RUNNING]"
    else
      stat="\e[1;31m[STOPPED]"
    fi

   echo -e "$stat \t\e[1;34m$target\e[0;0m\n"
 fi
}

daemons=$(ls /etc/rc.d/)

if [[ $1 != "" ]]
 then
  chk_status $1
else
  for d in $daemons
   do
    chk_status $d
  done | sort
fi

exit 0

HTH

Last edited by syntaxerrormmm (2009-03-20 20:43:25)


syntaxerrormmm - Homepage

Offline

#11 2009-03-20 20:56:16

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

thanks. edited


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#12 2009-03-20 20:57:19

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

syntaxerrormmm,

I tired your version which works, but there's 34 blank lines before the 34 lines of output.

Offline

#13 2009-03-21 03:03:42

toxygen
Member
Registered: 2008-08-22
Posts: 713

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

skottish wrote:

syntaxerrormmm,

I tired your version which works, but there's 34 blank lines before the 34 lines of output.

I was just about to ask about this...
I get the blanks too


"I know what you're thinking, 'cause right now I'm thinking the same thing. Actually, I've been thinking it ever since I got here:
Why oh why didn't I take the BLUE pill?"

Offline

#14 2009-03-21 09:56:35

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

toxygen wrote:
skottish wrote:

syntaxerrormmm,

I tired your version which works, but there's 34 blank lines before the 34 lines of output.

I was just about to ask about this...
I get the blanks too

that is happening because you have "echo -e" instead of "printf"


Just like this:

#!/bin/bash
# daemon status

 function chk_status(){
  target=$1
  if [ $target != "functions" ] && [ $target !=  "functions.d" ]
  then
    if [ -f "/var/run/daemons/$target" ]
     then
       stat="\e[1;32m[RUNNING]"
     else
       stat="\e[1;31m[STOPPED]"
     fi

    printf "$stat \t\e[1;34m$target\e[0;0m\n"
  fi
 }

 daemons=$(ls /etc/rc.d/)

 if [[ $1 != "" ]]
  then
   chk_status $1
 else
   for d in $daemons
    do
     chk_status $d
   done | sort
 fi

 exit 0

Last edited by quarkup (2009-03-21 09:59:44)


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#15 2009-03-21 09:59:02

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

< duplicated post - sorry >

Last edited by quarkup (2009-03-23 20:38:59)


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#16 2009-05-11 17:33:21

greenfish
Member
From: eating fish in /dev/null
Registered: 2008-08-30
Posts: 229

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

thanks a lot guys smile


ARCH64 archSKYNET server AMD  Phenom(tm) II X2 550 HDD 6TB Ram 8GB
Hobbies: Running, Pistol Marksmanship, Classic Music

Offline

#17 2010-11-22 22:53:01

Cisforcookie
Member
Registered: 2010-11-22
Posts: 1

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

Thanks for that.  Found this through a search.

Offline

#18 2010-11-22 23:38:10

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

This script should be packaged and maintained as part of [core].

Offline

#19 2010-11-24 21:18:14

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

Offline

#20 2011-02-11 02:38:28

Leo_Gutierrez
Member
From: México
Registered: 2011-02-07
Posts: 1

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

My script:

#!/bin/bash
[ $# -ne 1 ] && {
    echo -e "\n`basename $0` service\n";
    exit 1;
}
ls -1 /var/run/daemons/"$1" &> /dev/null && echo -e "$1 RUNNING" || echo -e "$1 STOPPED";

Offline

#21 2011-02-11 06:09:21

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: list running daemons - is there a rc-status like Gentoo? [SOLVED]

@Leo_Gutierrez - Whats the benefit of your script? You have to specify the service name to check its status.

Offline

Board footer

Powered by FluxBB