1

I use one of my Raspberry Pi as a headless desk clock and, apart from a reboot once a day which forces the OS to synchronise time to an NTP server, I would like to turn the WiFi off after that stage has completed, perhaps with a 10 minutes grace period in case I need to SSH in to perform maintenance.

Is there an easy way to do this?

  • A possibilty is to use timeout tool and down the interface in the programm arguments (but writing a proper script maybe is more usefull for cleaning ip addr on interface and other...) ex : timeout 10m ifconfig wlan0 down – Ephemeral Jul 14 at 12:21
  • If your network and NTP is done at raspberry start-up, just write a system unit file and put the timeout command ex: "ExecStart=timeout 10m ifconfig wlan0 down" that mean when the RPi start , the Rpi start your service and others services (ex:networking,you have internet) and then execute the ifconfig command after 10m (timeout). When the interface is put in down the connectivity is stopped (you have not internet). – Ephemeral Jul 14 at 12:29
  • Many thanks. I appreciate there are many ways to achieve the same result with Linux, such a powerful OS – Chorlton2080 Jul 16 at 21:52
2

We do not know anything about your setup. The simplest way is to start a service on boot up that just delays 10 minutes (e.g. sleep 600) and then disables wifi. Here an idea for a generic systemd Unit file but not tested:

[Unit]
Description=Delay terminate wifi
After=multi-user.target

[Service]
ExecStart=/bin/sleep 600
ExecStop=/sbin/wpa_cli -iwlan0 terminate

[Install]
WantedBy=multi-user.target
  • Fantastic! I'll give it a go. Many thanks. It'll get me using systemd finally, also. – Chorlton2080 Jul 16 at 21:52

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.