One way (not necessarily the best way) to disable wlan0
on your RPi is with rfkill
. Before going further, I should state the obvious for clarity: Once you've disabled wlan0
, it cannot be used to communicate with the device. So - if wlan0
is your only interface, you will need to do some planing; i.e. how to connect to your RPi in the absence of wlan0
.
That said, here's a cron
job that should do what you want:
Since rfkill
typically requires root
privileges, we'll use root
's crontab
for this:
$ sudo crontab -e
root crontab opens in your chosen default editor...
The following crontab
entries should toggle wlan0
ON at midnight (local time), and OFF again 3 minutes later:
0 0 * * * /usr/sbin/rfkill unblock wlan0
3 0 * * * /usr/sbin/rfkill block wlan0
Save your crontab
& exit the editor. That should meet your minimum requirement; I'll leave it to you to embellish the crontab
entries for output redirection - or development of a script to perform any related tasks.
You may also wish to consider how to handle things following a reboot
. Let us know if you have further questions.
raspbian
, so that narrows the range, but just to be clear, would you please confirm that you're using the defaultdhcpcd
as your network manager? – Seamus Aug 29 '22 at 14:23