LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 08-23-2007, 12:55 PM   #1
pobbz
LQ Newbie
 
Registered: Jul 2006
Distribution: Fedora, Debian, DSL
Posts: 24

Rep: Reputation: 15
klogd won't start


Hello.

I'm experiencing a quite strange problem: klogd won't start and I can't figure out how to fix this. I'm running Debian 4.0. The problem is manifested as follows.

First off, at boot I can see the following message pass by: Usage: /etc/init.d/klogd {start|stop|restart|force-reload}

Ok, so from this I figure that there's something wrong with the /etc/init.d/klogd script. So, after boot I fire up a shell, su, and then go to /etc/init.d and try the following:
Code:
p3:/etc/init.d# ./klogd start
Usage: /etc/init.d/klogd {start|stop|restart|force-reload}
As you can see, the same message appears as did during the boot.

Ok, so there must be something wrong with the /etc/init.d/klogd script. The problem is that I really can't see what might be wrong with it. The script is as follows.
Code:
#! /bin/sh
# /etc/init.d/klogd: start the kernel log daemon.

PATH=/bin:/usr/bin:/sbin:/usr/sbin

pidfile=/var/run/klogd.pid
binpath=/sbin/klogd

set KLOGD="-c 5"

test -f $binpath || exit 0

test ! -r /etc/default/klogd || . /etc/default/klogd

running()
{
    # No pidfile, probably no daemon present
    #
    if [ ! -f $pidfile ]
    then
        return 1
    fi

    pid=`cat $pidfile`

    # No pid, probably no daemon present
    #
    if [ -z "$pid" ]
    then
        return 1
    fi

    if [ ! -d /proc/$pid ]
    then
        return 1
    fi

    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1`

    # No syslogd?
    #
    if [ "$cmd" != "$binpath" ]
    then
        return 1
    fi

    return 0
}

case "$1" in
  start)
    echo -n "Starting kernel log daemon: klogd"
    start-stop-daemon --start --quiet --exec $binpath -- $KLOGD
    echo "."
    ;;
  stop)
    echo -n "Stopping kernel log daemon: klogd"
    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpath --pidfile $pidfile
    echo "."
    ;;
  restart|force-reload)
    echo -n "Restarting kernel log daemon: klogd"
    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpath --pidfile $pidfile
    start-stop-daemon --start --quiet --exec $binpath -- $KLOGD
    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/klogd {start|stop|restart|force-reload}"
    exit 1
esac

exit 0
Any help would be greatly appreciated.

Thanks.
 
Old 08-23-2007, 03:16 PM   #2
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie stretch buster
Posts: 1,769

Rep: Reputation: 107Reputation: 107
Hya,

I do not see obvious either, so there is a possibility that invisible character is hiding in your script.

Couple of things I would do.

edit the first line to "#!/bin/bash -v" and /etc/init.d/klogd start see what happens.
reinstall klogd package.

At least, your /etc/init.d/klogd is not identical to the one on my etch penguin. (although very similar).

Happy Penguins!
 
Old 08-24-2007, 04:45 AM   #3
pobbz
LQ Newbie
 
Registered: Jul 2006
Distribution: Fedora, Debian, DSL
Posts: 24

Original Poster
Rep: Reputation: 15
Hello.

I reinstalled klogd package through synaptic and modified the first line of the klogd script to read #!/bin/bash -v

Then I said
Code:
/etc/init.d/klogd start
Now it prints out the whole script to console and then after that there still is the line
Code:
Usage: /etc/init.d/klogd {start|stop|restart|force-reload}
This is really strange. No errors are printed. Other scripts under /etc/init.d seem to work flawlessly.

And now I don't know how there could be any hidden characters in there as I just reinstalled the package.

I very here.
 
Old 08-24-2007, 04:58 AM   #4
pobbz
LQ Newbie
 
Registered: Jul 2006
Distribution: Fedora, Debian, DSL
Posts: 24

Original Poster
Rep: Reputation: 15
Hello again.

I think I'm getting somewhere now. But I still need help as I'm not quite an expert in BASH scripting. What I did is that I added some lines to my klogd script to print out the value of $1 as it seemed that the argument of the script ('start' in my case) didn't end up for the case statement. And that really seems to be the case. Please see the script below and the output and tell me how to fix this.
Code:
#!/bin/sh
# /etc/init.d/klogd: start the kernel log daemon.

echo "The first argument is $1"

PATH=/bin:/usr/bin:/sbin:/usr/sbin

pidfile=/var/run/klogd.pid
binpath=/sbin/klogd

set KLOGD="-c 5"

test -f $binpath || exit 0

test ! -r /etc/default/klogd || . /etc/default/klogd

running()
{
    # No pidfile, probably no daemon present
    #
    if [ ! -f $pidfile ]
    then
        return 1
    fi

    pid=`cat $pidfile`

    # No pid, probably no daemon present
    #
    if [ -z "$pid" ]
    then
        return 1
    fi

    if [ ! -d /proc/$pid ]
    then
        return 1
    fi
    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1`

    # No syslogd?
    #
    if [ "$cmd" != "$binpath" ]
    then
        return 1
    fi

    return 0
}

echo "Now the first argument is $1! This should not be the case."

case "$1" in
  start)
    echo -n "Starting kernel log daemon: klogd"
    start-stop-daemon --start --quiet --exec $binpath -- $KLOGD
    echo "."
    ;;
  stop)
    echo -n "Stopping kernel log daemon: klogd"
    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpath --pidfile $pidfile
    echo "."
    ;;
  restart|force-reload)
    echo -n "Restarting kernel log daemon: klogd"
    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpath --pidfile $pidfile
    start-stop-daemon --start --quiet --exec $binpath -- $KLOGD
    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/klogd {start|stop|restart|force-reload}"
    exit 1
esac

exit 0
Code:
p3:/etc/init.d# ./klogd start
The first argument is start
Now the first argument is KLOGD=-c 5! This should not be the case.
Usage: /etc/init.d/klogd {start|stop|restart|force-reload}
p3:/etc/init.d#
Please help me here.

Last edited by pobbz; 08-24-2007 at 05:10 AM.
 
Old 08-24-2007, 05:19 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
Save the args on input to a variable. Add a line CLI_ARGS="$1" above the first "echo "The first argument is $1"" line, then change all instances of "$1" to "$CLI_ARGS".
 
Old 08-24-2007, 05:37 AM   #6
pobbz
LQ Newbie
 
Registered: Jul 2006
Distribution: Fedora, Debian, DSL
Posts: 24

Original Poster
Rep: Reputation: 15
Hey, thanks dude! That did the trick! Now /var/log/kern.log seems to get updated and ps aux shows that klogd is running.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'klogd' problem NervusMagnus Linux - Newbie 3 05-27-2007 03:11 PM
klogd and syslog asahlot Linux - Kernel 1 09-22-2006 10:35 AM
why my ssytem have klogd and syslogd? xcore_on Linux - Newbie 1 05-21-2006 09:34 AM
klogd - how to use full version sceadu Linux - General 0 04-22-2005 09:16 AM
can i delete syslogd, klogd? lmmix Linux - Security 9 03-10-2005 05:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 04:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration