You are not logged in.
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
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
thanks! I really appreciate it, after reading the script I feel a little foolish!
Offline
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
#!/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
[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
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)
Offline
nice!
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
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
... 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
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
syntaxerrormmm,
I tired your version which works, but there's 34 blank lines before the 34 lines of output.
Offline
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
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
< 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
thanks a lot guys
ARCH64 archSKYNET server AMD Phenom(tm) II X2 550 HDD 6TB Ram 8GB
Hobbies: Running, Pistol Marksmanship, Classic Music
Offline
Thanks for that. Found this through a search.
Offline
This script should be packaged and maintained as part of [core].
Offline
Oh, and then there's this: http://aur.archlinux.org/packages.php?ID=30414
Offline
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
@Leo_Gutierrez - Whats the benefit of your script? You have to specify the service name to check its status.
Offline