Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]

share|improve this question
up vote 0 down vote accepted

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
share|improve this answer
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 '12 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 '12 at 19:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.