Question

I had the following question in a test:

"Each time that the system is order to shut down, register the following message -System stopped at hh:mm:ss from dd/mm/yyyy-, at /root/log_stop"

the question is that, I would really like how can I know that :D

thank you very much.

Was it helpful?

Solution

I think this might be an answer:

--->edit /etc/rsyslog.conf

in the global directives we can establish the format (I'd like to know how can I create my own template, that would be another question), once we have the template desired in rules I can redirect the messages from any daemon trough that file, which daemon can I redirect? this ones:

kern user mail daemon aut syslog syslogd lpr cron local0-7

if you need more info check the manual entry for /etc/rsyslog.conf

PS: I'm still not sure this is the answer, I think it MIGHT be one answer, can anyone help me? :D

OTHER TIPS

The simplest answer is to use an init script. Make /etc/init.d/shutdownmessage

#!/bin/sh
echo System stopped at `date` >> /root/log_stop

Then link it in runlevels 0 and 6 for shutdown and reboot

ln -s /etc/init.d/shutdownmessage /etc/rc0.d/S00shutdownmessage
ln -s /etc/init.d/shutdownmessage /etc/rc6.d/S00shutdownmessage

You can look at the date command to get the formatting you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top