Automate the "tail" command ????


Recommended Posts

I've seen this:

 

Probably the easiest way to do this is open a telnet window and type:

 

tail  -f  /var/log/syslog

 

This will output the last few lines of the system log and then each time a new message is generated it will print in the telnet window.  Then if some kind of error is leading up to the crash you should be able to select/copy/paste & post it here.

 

Is there any way to automate this, i.e. automaticaly (on boot) login and execute this as in a batch file on a PC ?

Link to comment
  • 2 weeks later...

Do you mean that after you open a  telnet session to your server and login, you want it to automatically exeucte that 'tail' command?

 

actually, I'd like it to execute unattended without logging on at all.... like autoexec.bat in DOS... ??

 

 

I'm sure there is a way to do this via inittab

 

tail:345:respawn:/usr/bin/tail -f /var/log/messages > /dev/tty12

 

Perhaps even automating the vt switch.

 

tail:345:respawn:/usr/bin/switchto 12;exec /usr/bin/tail -f /var/log/messages > /dev/tty12

 

 

 

 

Link to comment

Find the entry in /etc/syslog.conf pointing to /var/log/messages. Copy the message reporting levels but change the device they point to, to tty1:

 

*.info;*.!warn;authpriv.none;cron.none;mail.none;news.none     -/dev/tty1

 

(make sure to seperate news.none and -/dev/tty1 with at least 1 TAB, not spaces)

 

save the file and restart the syslog daemon

pkill -HUP syslogd

 

Now all your messages will go to tty1, which is the default tty upon boot.  To scroll the messages, use [shift-page up] and [shift-page down].

Use [ctrl-shift-F2] to get to tty2, F3 for tty3, etc...  Back to F1 for the messages.

 

The other option, is to substitute -/dev/tty1 with @123.456.789 (ip address of a PC you keep on all the time). Install kiwi syslog daemon (free version) http://www.kiwisyslog.com/syslog-info.php as a service on the PC. The syslog facility on the OS will forward the messages to your PC. Kiwi will capture the messages for you to read.

Link to comment

great advise...  unfortunatly, when you reboot the unRaid server will replace your edited syslog.conf with its original one.

 

You might be able to copy the edited file to /boot

 

Then, add a line to the "go" script to copy it back to /etc/syslog.conf, followed by a second line to restart the syslog daemon

 

like this...

cp /boot/syslog.conf /etc/syslog.conf

pkill -HUP syslogd

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.