1

I need to write a "one-liner" in /etc/network/interfaces that ensures that when eth1 goes up/down a file /var/log/network.log is written with something like that UP/DOWN [DATE/TIME]

EX: UP [10-12-2012/21:30:00]

The format is [DD-MM-YY/HH-MM-SS]

If eth1 is active put in /var/log/network.log UP [DATE/TIME] if eth1 is DOWN put in /var/log/network.log DOWN [DATE/TIME]

1 Answer 1

1

First a very simple approach.

iface eth1 inet dhcp
    ...
    up echo $IFACE up $(date) >> /var/log/network.log
    down echo $IFACE down $(date) >> /var/log/network.log

A more adequate approach would use the syslog facility so that the logfile gets rotated, etc. The following will log to /var/log/syslog.

iface eth1 inet dhcp
    ...
    up echo $IFACE up $(date) | logger -p local0.notice
    down echo $IFACE down $(date) | logger -p local0.notice
2
  • Thanks. Could you tell me how to make apache2 to listen only on port 8080 and how to change the root folder to /home/alex/public_html
    – Alex
    Dec 18, 2012 at 18:09
  • No problem. Just create a new question for this, please. And if the above answer was useful to you, please vote it up... or even, dare I say, accept it. ;)
    – jdthood
    Dec 18, 2012 at 19:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .