Doubt regarding "init q"


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Doubt regarding "init q"
# 1  
Old 06-17-2003
Question Doubt regarding "init q"

I am writing a script for the installation of a new version of my executable. The process is started from inittab. The script does the following
1.Comment the process entry from inittab.
2."init q"
3.replace the old executable with the new one
4.Uncomment the entry in initttab
5.init q

Now the process is stopped and the new version is copied. But it is not getting restarted. But if i do these steps manually from the shell the process is getting spawned.

Another interesting observation i had was that if i put a sleep between step 3 & 4 , the process will start.

My doubts are
1) will "init q" check the timestamp of inittab before reading it? (Here if i do it from script it will take less than a second)

2) Is there any other condition,where "init q" wont read inittab?
# 2  
Old 06-18-2003
First off, you don't need to do step 1, 2, or 4. All you have to do is replace the old executable with the new, possibly add a sleep to allow any write cache to clear, and do the init q command.

When making changes like this, the init process isn't re-reading/reloading anything until you do the init q. So you could replace any executable that is run by init and it will not update until the init q (or a reboot).

I don't believe the file timestamp is checked since you are running the init q command.

From the man page for init:

New entries can be added to /etc/inittab at any time; how-
ever, init still waits for one of the above three conditions
to occur before re-examining /etc/inittab. To get around
this, init Q or init q command wakes init to re-examine
/etc/inittab immediately.
# 3  
Old 06-18-2003
It actually would not surprise me if init stat's the file and passes on the reread is the timestamp hasn't changed. That is a common performance hack.

There is a slight problem with replacing a running program. Unix will not allow a unlink() of a file if it is a running process. You will get a "text busy" error message. So you just rename the old one and install a new one. Then perhaps kill the running process to trigger a respawn. Yes this does leave a slight window when init may freak if it can't find a file for a respawn. But init will catch it and sleep with the "respawning too rapidly" error message.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Red Hat

INIT: Id "x" respawning too fast

Hi, OS: Oracle Enterprise Linux 4 My system was working normal then when i reboot the machine the system started but it is halting the boot sequence with this message "INIT: Id "x" respawning too fast: disabled for 5 minutes" Q: any solution to this reply is highly appreciated . (5 Replies)
Discussion started by: maooah
5 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Red Hat

INIT: cannot execute "/etc/X11/prefdm"

Hi I tried the following but no joy! Inserted the linux installation cd.. ( rescue mode)... tried chroot /mnt/sysimage but I get chroot: cannot execute /bin/sh Checked the permission on /bin and it was set to ?r--rw-rx tried to do chmod –R 755 but got error operation not permitted ...... (3 Replies)
Discussion started by: halacil
3 Replies

7. Solaris

How to resolve error "INIT: Cannot stat /etc/inittab, errno: 2"

Hi All, I am getting an error message when I execute command “zlogin -C sunsrv4z5” on my root server. INIT: Cannot stat /etc/inittab, errno: 2 INIT: Cannot stat /etc/inittab, errno: 2 As per my analysis it seems that some files inside /etc folder are deleted. This server was... (14 Replies)
Discussion started by: surbhit4u
14 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. Debian

Debian: doubt in "top" %CPU and "sar" output

Hi All, I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel). For my application: <sar -U ALL> CPU %user %nice %system %idle ... 10:58:04 0 153.10 0.00 38.76 0.00 10:58:04 1 3.88 0.00 4.26 ... (0 Replies)
Discussion started by: jaduks
0 Replies
Login or Register to Ask a Question