View previous topic :: View next topic |
Author |
Message |
john7002 Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/1115763323422b822da1791.jpg)
Joined: 21 Jan 2004 Posts: 238 Location: United Kingdom
|
Posted: Tue Jan 27, 2004 11:36 pm Post subject: log file |
|
|
Hi,
I'd like to create a log file which can allow me to know when my provider change my IP. I just need to know the date and the hour of the disconnection. Does anyone know?
Thanks |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
hadfield Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/gallery/Zelda/Zelda_-_Link.jpg)
Joined: 18 Mar 2003 Posts: 308 Location: Vancouver, BC, Canada
|
Posted: Wed Jan 28, 2004 12:00 am Post subject: |
|
|
The dhcp information your looking for is located at /etc/dhcpc/. I'm not sure if these files are only modified on reboot or by the dhcpc daemon, but I think they're modified by the daemon. You could make a copy of the current files and put them into a log, say at /var/log/dhcpc. You could have a log file for every interface using dhcp. So one might look like /var/log/dhcpc/dhcpcd-eth0.log. It would contain the concatenation of all changed dhcpcd-eth0.info files. Then write a small cron job that gets executed on an hourly basis it would just need to check the timestamp on the dhcpcd-eth0.info file and compare it with the dhcpcd-eth0.log file, if the info file is newer, then concatenate the new info file to the log. I'll see if I can come up with something and post it here if I do. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
hadfield Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/gallery/Zelda/Zelda_-_Link.jpg)
Joined: 18 Mar 2003 Posts: 308 Location: Vancouver, BC, Canada
|
Posted: Wed Jan 28, 2004 12:25 am Post subject: |
|
|
Ok, this might work:
Code: |
#!/bin/bash
if [ /etc/dhcpc/dhcpcd-eth0.info -nt /var/log/dhcpc/dhcpcd-eth0.log ]; then
echo -e "\ndhcpcd info added at `date`"
cat /etc/dhcpc/dhcpcd-eth0.info >> /var/log/dhcpc/dhcpcd-eth0.log
fi
|
I haven't actually tested this, but it should work. Just put it in a file in cron.hourly and it should get executed every hour.
Hope this helps.[/code] |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
john7002 Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/1115763323422b822da1791.jpg)
Joined: 21 Jan 2004 Posts: 238 Location: United Kingdom
|
Posted: Wed Jan 28, 2004 12:28 am Post subject: |
|
|
thank you very much ! I'll test it tomorrow... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|