LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-24-2014, 02:27 PM   #1
jddancks
LQ Newbie
 
Registered: Jan 2013
Location: Central NY
Distribution: Mac, debian
Posts: 29

Rep: Reputation: Disabled
Debugging an /etc/init.d service when it fails silently


The service I'm interested in is named. I do something like:

Code:
[root@test master]# service named start
Starting named:                                            [FAILED]
I tried to test by replacing all instances of /dev/null with /var/log/maned.log:

Code:
[root@test master]# sed -i 's/\/dev\/null/\/var\/log\/named.log/g' /etc/init.d/named
The changes were made successfully, but nothing get written. I don't know what to do.

strace spits out code which being a shell scripting newbie I don't understand. And there is a lot of it. I'm not sure what else to do
 
Old 11-24-2014, 06:15 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,578

Rep: Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565Reputation: 1565
The named service normally logs some information when it starts up. Does anything show up in /var/log/messages?
 
Old 11-24-2014, 06:58 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,360
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
More specifically services themselves often have their own command line switches or configuration directives that govern what is logged (silent, verbose, debug mode) and where (chroot, var/log). On top of that SysV init scripts may source (additional) switches from the central location (if any) your Linux distribution designated for such configuration. That's at least three locations to look for. Note editing SysV init scripts is generally considered not done for various reasons.
 
Old 11-24-2014, 08:49 PM   #4
jddancks
LQ Newbie
 
Registered: Jan 2013
Location: Central NY
Distribution: Mac, debian
Posts: 29

Original Poster
Rep: Reputation: Disabled
I found out that the binary exists in /usr/sbin/named, and in fact will take command line arguments. so I used that. And that helped a lot but for some reason the output and behavior of the init.d script is different (probably why it exists lol). init.d script was what I was more interested in debugging. It got pointed out that simply replacing /dev/null with /var/log/named.log left the single arrow so that it overwrote the file whenever the command was called. But there should've been at least 1 line of something in the file. Unless it still writes/redirects even if stderr isn't written to???

I did try logging and nothing came of it. I believe in order for logging to happen the binary has to actually start and the init script wouldn't let it.
 
Old 11-25-2014, 08:15 AM   #5
jameshofmann
LQ Newbie
 
Registered: Mar 2006
Posts: 7

Rep: Reputation: 0
Just yesterday I had occasion to do the same thing you're doing. I inserted "logger" commands into the script [I] wanted to learn about, and and when I ran the script the message came out in the /var/log/syslog file with the word "logger" attached. Very handy.

From my limited experience, logger seems to work like echo, and prints a string. Of course, see man logger for the real answer. Example ( in the script ) ... logger "var:$var"
on a line by itself.
 
Old 11-25-2014, 09:00 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,711

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
Redirection (>) of output ALWAYS truncates the file to 0 length by the shell. The application has nothing to do with that.

Named being a service, is already programmed to NOT USE STDOUT/STDERR. These are usually just ignored. There ARE options that will direct named to write debugging information - but these usually have to be run in an interactive mode, thus they also disable the forking of the daemon process.

MOST of the init scripts for named will have an options feature that allows turning on nearly any debugging you want.
 
  


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
grub 0.97 on sda2 (NTFS) fails silently on "Loading stage2" arielCo Linux - General 3 04-29-2009 08:24 AM
Printing this PDF silently fails KenJackson Linux - Software 3 02-12-2008 03:32 PM
Installing Packages Fails: Silently pizmooz Slackware - Installation 2 06-21-2006 01:30 AM
NE2000-PCI detection fails silently dregoma Linux - Networking 0 07-14-2003 08:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration