0

I would like to know the last time my Raspberry Pi Zero (1.7W) was connected to the internet.

OS: Raspberry Pi OS Lite, Kernel version: 5.15 & Debian version: 11 (bullseye)

There was a similar question asked using an Ubuntu machine. However, it has additional capabilities, i.e., a Network Manager. Seems like a solution could be analyzing the /var/log/syslog output but, I am unsure what to sift through using awk or grep.

My goal is to see that if the last time there has been a network connection, and it has has been greater than 18 hours run a script.

Thanks.

2
  • 1
    you may get better results by asking at a linux site, since your question is not really about Raspberry Pi
    – jsotola
    Apr 15 at 1:08
  • Check the connection pages on your router. Linux doesn't bother recording that info as it has no use or relevance.
    – Dougie
    Apr 15 at 14:33

1 Answer 1

1

Depends what you mean by "connected to the internet".

All network managers (using DHCP) connect to a DHCP server (usually your router). systemctl status dhcpcd will show when Raspberry Pi OS obtained its lease.

The OS does NOT "connect to the internet" - various processes running may, but you would need to check these.

Probably the most frequent connection to the internet is done by timesyncd.

On Raspberry Pi OS systemctl status systemd-timesyncd.service will show initial sync and timedatectl timesync-status will show detail.
On my system this shows Poll interval: 34min 8s (min: 32s; max 34min 8s) i.e. 2048 seconds and /var/lib/systemd/timesync/clock will show the time this was done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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