Operating System - HP-UX
1825768 Members
1986 Online
109687 Solutions
New Discussion

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

 
SOLVED
Go to solution
incle
Advisor

after modify /etc/inittab, my daemon never work, unless reboot the machine

after modify /etc/inittab, my daemon never work, unless reboot the machine
16 REPLIES 16
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

After modify the /etc/inittab file, then
i type 'init q', 'init Q' or 'telinit q' anyway, my daemon process cannot start.

my modification as following:
mydm:2345:respawn:/sbin/mydm

but if reboot the machine, then everything is ok. (every times)

why and how can I deal with this problem?
( I want to after modify the /etc/inittab and type 'init q' then my process immediately running. need not reboot)

thanks
--Incle
Amit Parui
Valued Contributor
Solution

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

Can you brief what modifications have you done in you /etc/inittab? Have you got a copy or backup of /etc/inittab file before changes done, check out the differences.

diff changed previous
If Life gives u a ROCK, its upto u to build a BRIDGE or a WALL !!!
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

#!/bin/bash

echo "Let's begin"

[ -f /home/incle/daemon_other ] && {
while fgrep daemon_other /etc/inittab >/dev/null
do
echo -e "/daemon_other\nd\nw\nq\n" | ed /etc/inittab - >/dev/null
done
echo -e "$\na\ndoor:2345:respawn:/home/incle/daemon_other\n.\nw\nq\n" |
ed /etc/inittab - >/dev/null

/sbin/init q
}
[ -f /home/incle/daemon_loop ] && {
while fgrep daemon_loop /etc/inittab >/dev/null
do
echo -e "/daemon_loop\nd\nw\nq\n" | ed /etc/inittab - >/dev/null
done
echo -e "$\na\ndaem:2345:respawn:/home/incle/daemon_loop\n.\nw\nq\n" |
ed /etc/inittab - >/dev/null

/sbin/init q
}
echo "Good job, bye!"
Dennis Handly
Acclaimed Contributor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

>And you mean that I should use 'sh' as my shell in the script.

Yes, actually /sbin/sh.

>in my HP machine the /usr never mounted.

/usr/ is mounted with the rest of the file systems when you go to multiuser mode.

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

Well what's your current/deafult run-level?

who -r

grep initdefault /etc/iniitab

HTH

Duncan

I am an HPE Employee
Accept or Kudo
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

>> /usr/ is mounted with the rest of the file systems when you go to multiuser

mode.
how to make /usr/ isnt't mounted? changes the runlever?


>> Well what's your current/deafult run-level?
bash-3.2# who -r
. run-level 3 Sep 29 10:25 3 0 S
bash-3.2# grep initdefault /etc/inittab
init:3:initdefault:
Dennis Handly
Acclaimed Contributor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

>how to make /usr/ isn't mounted? change the run level?

The easiest is to boot into single user mode.

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

hmmm - can we do a little test here to confirm this is an init problem and not your daemon (as root):

cat > /init-test <#!/sbin/sh
while true do
sleep 10
done
EOF

chmod u+x /init-test

echo "test:2345:respawn:/init-test" >> /etc/inittab

init q

ps -ef | grep init-test

Do you see the process running or not?

(This little test works fine on my system)

Don't forget to remove this test line from inittab and 'init q' after running all this.

HTH

Duncan

I am an HPE Employee
Accept or Kudo

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

oops - typo:

cat > /init-test <#!/sbin/sh
while true
do
sleep 10
done
EOF

chmod u+x /init-test

echo "test:2345:respawn:/init-test" >> /etc/inittab

init q

ps -ef | grep init-test

I am an HPE Employee
Accept or Kudo
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

bash-3.2# vi /etc/inittab
init:3:initdefault:
.
.
.
.
/etc/opt/resmon/persistence/runlevel4_flag"
ems4:0123456:respawn:/etc/opt/resmon/lbin/p_client



----
bash-3.2# ./daemon.sh
+ echo Let's begin
Let's begin
+ [ -f /home/incle/daemon_other ]
+ fgrep daemon_other /etc/inittab
+ 1> /dev/null
+ ed /etc/inittab -
+ echo -e $\na\ndoor:2345:respawn:/home/incle/daemon_other\n.\nw\nq\n
+ 1> /dev/null
+ /sbin/init q
+ [ -f /home/incle/daemon_loop ]
+ fgrep daemon_loop /etc/inittab
+ 1> /dev/null
+ echo -e $\na\ndaem:2345:respawn:/home/incle/daemon_loop\n.\nw\nq\n
+ ed /etc/inittab -
+ 1> /dev/null
+ /sbin/init q
+ echo Good job, bye!
Good job, bye!
bash-3.2#
bash-3.2#
bash-3.2# ps -ef|grep daemon_
root 3015 2919 1 11:07:29 pts/ta 0:00 grep daemon_
root 3009 1 153 11:06:34 ? 0:54 /home/incle/daemon_other
bash-3.2#
bash-3.2# uname -a
HP-UX l1000 B.11.11 U 9000/800 545706547 unlimited-user license
bash-3.2#
bash-3.2#init Q
bash-3.2# ps -ef|grep daemon_
root 3020 2919 2 11:08:37 pts/ta 0:00 grep daemon_
root 3009 1 229 11:06:34 ? 2:02 /home/incle/daemon_other
bash-3.2#


-----
bash-3.2# vi /etc/inittab
init:3:initdefault:
.
.
.
./etc/opt/resmon/persistence/runlevel4_flag"
ems4:0123456:respawn:/etc/opt/resmon/lbin/p_client
door:2345:respawn:/home/incle/daemon_other
daem:2345:respawn:/home/incle/daemon_loop
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

bash-3.2# chmod u+x init-test
bash-3.2# ls -lat init-test
-rwxrw-rw- 1 root sys 39 Sep 29 11:26 init-test
bash-3.2# echo -e "test:2345:respawn:/home/incle/init-test">>/etc/inittab
bash-3.2# init q
bash-3.2# ps -ef|grep init-test
root 3054 1 0 11:27:57 ? 0:00 /sbin/sh /home/incle/init-test
root 3058 2919 1 11:28:08 pts/ta 0:00 grep init-test
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

see also in my running the ./daemon.sh

you can see just the first(daemon_other) daemon work, but the second(daemon_loop) never work.
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

And I found use the same script(daemon.sh) to run this daemons( daemon_loop and daemon_other) was OK on RedHat linux-2.6
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

hi, friends. do you got the same problem?
and how to deal with it?
tkc
Esteemed Contributor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

hi incle, try assigning points to those who have assisted you. this will encourage more people to participate in the forum. :)
incle
Advisor

Re: after modify /etc/inittab, my daemon never work, unless reboot the machine

thanks your advice.