How to add a entry in inittab?

Hi All,

I am booting by Linux box with the run level 3 and it gets booted successfully.

I want to execute a script once the system is up and running in the run level 3. I was trying to add a entry to /etc/inittab to execute my script once the system is up.
I have added the below ennty to the /etc/inittab. But it does not execute the script the script when the box came up.

1:3:once://opt/myscript

Thanks,
Kalai

did you follow that on the console?
and you can change the id for to execute that without duplicate id(1) warning.
try to add after the "initdefault" line..

sh:3:once:/opt/myscript

Why do you want to add the entry to /etc/inittab? The more usual approach (assuming a SysV rc) is to add the script into /etc/init.d and then symbolically link to this script from /etc/rc3.d/SXXscript and/or /etc/rc3.d/KXXscript.

Thanks a lot.

If I add this condition after the id:3:initdefault: , will it be executed after all the required service is started for the run level 3.

---------- Post updated at 10:32 PM ---------- Previous update was at 10:30 PM ----------

I want to execute my script, once the system is up and running in Level 3. My script needs to be executed only after all the required service is up and running for Level 3.
Due to this planed to add it in inittab. Please correct me if my understanding is wrong.

Kal,

This is going against the entire purpose of what init does. You should stop trying to kludge together a solution and use the appropriate tools for the job.

Sure, you can drive screws into walls with a brick, but you end up with lackluster, and unsupportable structures.

Write an init script and put it into the appropriate rc directory. chkconfig it on.

Your understanding is wrong. The inittab line you posted would be executed immediately run state 3 started (if it was typed correctly).

There should be a line in inittab already which runs the rc process and it is this process which starts or stops all processes on entry or exit from a run state. See man rc and the comments from other posters above.