1832973 Members
2383 Online
110048 Solutions
New Discussion

Inittab

 
Dave Elliott
Frequent Advisor

Inittab

I want to change the following entry in inittab so that it doesn't just send output to dev/console but to a file, i thought about using the TEE command but wondered if anyone has done this before or could offer advice on possible construct.

brc1::bootwait:/sbin/bcheckrc /dev/console 2>&1 # fsck, etc.
Oracle DBA
15 REPLIES 15
U.SivaKumar_2
Honored Contributor

Re: Inittab

Hi,
I wont recommend to change that line.

regards,
U.SivaKumar
Innovations are made when conventions are broken
Dave Elliott
Frequent Advisor

Re: Inittab

Iknow that this i high risk, i am trying this on a test system where i am the only person who uses it so no problem.
but i think that it should be possible as at the end of the day it is a script and therefore as long as i get the syntax correct should work.
worst case is i have to boot to single user mode and copy the orig file back in and restart.
Oracle DBA
Stefan Farrelly
Honored Contributor

Re: Inittab

I think the format to try should be;

brc1::bootwait:/sbin/bcheckrc &1 | tee /brc1.log >/dev/console


But im not sure that at the point this runs that any filesystem is mounted except / but you may have to try /stand instead for the logfile.
Im from Palmerston North, New Zealand, but somehow ended up in London...
U.SivaKumar_2
Honored Contributor

Re: Inittab

Hi,
brc1::bootwait:/sbin/bcheckrc > /home/bceck 2>&1
will be enough for that.

regards,
U.SivaKumar
Innovations are made when conventions are broken
Stefan Farrelly
Honored Contributor

Re: Inittab


On second thought it might not be able to find the tee command as its in /usr/bin, you may need to copy to /sbin first then change command to;

brc1::bootwait:/sbin/bcheckrc &1 | /sbin/tee /brc1.log >/dev/console
Im from Palmerston North, New Zealand, but somehow ended up in London...
Trond Haugen
Honored Contributor

Re: Inittab

Stefan is right about tee not being available because no dirs but / is mounted yet. For the same reason U.SivaKumar suggestion should put the file on / too.

regards,
Trond
Regards,
Trond Haugen
LinkedIn
Frank Slootweg
Honored Contributor

Re: Inittab

And copying [/usr/bin/]tee to /sbin will not help, because /usr/bin/tee uses shared libraries ("chatr /usr/bin/tee"), which are on /usr, which is not yet mounted.
Luc Bussieres_1
Trusted Contributor

Re: Inittab

Hello,


With tee being in /usr/bin you cannot achieve what you want to do. The file in that directory are dinamically linked and they need the library that are in /usr/lib so even movin tee in /sbin won't work. You will need the source code of tee and rebuild it statically link.

Luc
Stefan Farrelly
Honored Contributor

Re: Inittab


All this talk about tee not working if copied to /sbin - baloney. Ive just tried it in my inittab file and it worked absolutely fine!

Im from Palmerston North, New Zealand, but somehow ended up in London...
Dave Elliott
Frequent Advisor

Re: Inittab

How i have tried it in the initab file and everything still works the way you would expect excetp that there is no file created.
Oracle DBA
Stefan Farrelly
Honored Contributor

Re: Inittab

Hi Andrew,

ah, thats because exec cant handle the pipe character which means you cant use tee, you need to do it in 2 stages this way (works fine on my test server);

brc1::bootwait:/sbin/bcheckrc /brc1.log 2>&1 ; cat /brc1.log >/dev/console

Im from Palmerston North, New Zealand, but somehow ended up in London...
Frank Slootweg
Honored Contributor

Re: Inittab

Stefan, I am afraid that "All this talk about tee not working if copied to /sbin - baloney.", isn't baloney!

You imply that you have tried it, but later you say "exec cant handle the pipe character which means you cant use tee", so I guess you did *not* actually try it, or did not try it with a reboot, etc..

Even if you did try it with a reboot, you still might have been 'lucky', because, as I wrote, /usr/bin/tee *does* use shared libraries, so it could fail under certain circumstances (different LANG?) and you don't want failures at boot time, especially not for bcheckrc.
Stefan Farrelly
Honored Contributor

Re: Inittab


Look Frank, I DID try it - you clearly didnt. Wind your neck in.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Frank Slootweg
Honored Contributor

Re: Inittab

Stefan,

Let's please scale down the tone a bit.

Please post which command you did try, because from your postings it is not clear (i.e. contradictory information).

For what it is worth, I only warned about the dangers, i.e. using an executable which uses shared libraries, without /usr mounted is asking for trouble. I don't think it is wise to implement something which happens to 'work' if you know that there potential problems with the approach (i.e. in this case missing shared libraries).
A. Clay Stephenson
Acclaimed Contributor

Re: Inittab

My first impression (without reading any of the responses) was that this can't possibly work because it would require that /usr be mounted even if tee were moved to /sbin because tee requires shared libraries.

If you do an ldd /usr/bin/tee, you will find that indeed requires shared libraries.

If you really wanted to do this, it would be quite easy to code a statically linked equivalent of tee and put it in /sbin. This should be only a few lines of C.
If it ain't broke, I can fix that.