script with output to console 2 ?
Have a question - it is possible to make autostart script, with output of that script going to console 2, or 3?
exactly, i want to make a
tail -f /data/recv.log
with output to console 2, i can do that, for sure, manually - log in in console 2, then run that command, but it is possible to automate this?
found it can be done with redirection to console - like as
tail -f /data/recv.log > /dev/tty2
also if i put that line in /etc/rc.d/rc.local , i think, startup procedure stops at this command, because it never ending and run continually.
i think, construction must be like
tail -f /data/recv.log > /dev/tty2 &
to put that command in background?
than all must be work?
there are a problem with output redirecting to console 2 - ">/dev/tty2" - it not work. today i start system, and on console 2 ( ALT +F2) i see only login screen - not any messages....
anyone can help me with this?
I am unsure in my guess. Well, I don't think /dev/tty2 actually connected to console display in moment of execution of rc.local. I believe it connects to display during execution of command "/sbin/agetty 38400 tty2 linux", which according to inittab will be executed only and only after rc.M terminates itself. So you have a kind of deadlock here.
hm. thank for idea. and where i can, then, write my command to do execute it on startup?
as i understand, rc.m is last script, who autoexecute on startup, and rc.local is last call from rc.m...?
Yes, rc.M is last before spawning tty's.
Let analyse your task:
You want some startup sciprt to continuously print content of interactive log file (/data/recv.cfg) to some tty(let it be tty2)?
I see next solution:
1. Let prepare command to print log. We shall put into /root/logger
2. We know it is possible after actual connecting tty2 to console(made by agetty).
So our task is to force to call our logger during spawning on tty. Well, after brief reading of "man agetty" and "man inittab"(for testing purposes) solution is oblivious for me.
Go edit /etc/inittab (do backup!!!)
find line "c2:12345:respawn:/sbin/agetty 38400 tty2 linux"
and replace it by line "c2:12345:respawn:/sbin/agetty -n -l /root/logger 38400 tty2 linux"
"-n" means do not prompt username
"-l /root/logger" means run given executable instead standard /sbin/login.
To test it:
1. Completely logoff on tty2(if logged on), switch back to non-tty2.
2. Ask init to re-read /etc/inittab using command: @ telinit q
3. Terminate corresponding tty console by command: @ kill -s $(ps a |grep agetty |grep tty2 |cut -f 1 -d" ") OR use top/htop/... to kill tty2.
init will rerun corresponding process immediately but with new parameters(actually, you can change not only parameters but whole command, it identifies process to rerun by its id, "c2" in out case).
Switch to tty2(alt+f2) now you can see content of your log file in that tty.
As a side effect you cannot login in tty2 any more. Probably there are other side effects, this will be your homework.
thank you very much for this workaround, but i be sure, it can be more easy and logic way to get messages output to console 2,3, so.
in fact, many distro in different time do that - as i remember, one time mandrake distro in installation process do various data outputs to various consoles and so on. i think, there must be another variants, without inittab edition, because this is not a nice solution imho.
Running job at statup (boot)
You need to use special string called @reboot. It will run once, at startup after reboot command.
it works. but my output of /var/log/messages to console via tail -f script is some strange formatting - looks like without CR feed. look, what i correct that.
|All times are GMT -5. The time now is 07:51 PM.|