Help with cron disabling wifi

Hello everyone been using ipfire on a APU2E0 with a WLE200NX. Everything seems solid. After using it for a while I would like to turn off wifi. Is it possible via cron or would everyone agree that it is easier just blocking internet access? I am looking to turn off wifi from 00:00 - 06:00. My cron would be as follows:

00 00 * * * wifi down
00 06 * * * wifi up
in fcrontab

Please go easy on me. All advise welcome. Thanks in advance.

You will just need to start/stop hostapd, but I’m not sure for the command on ipfire. You will need to try it out, something like

stop hostapd

I first thought thats possible with connection scheduler but seems thats wrong.

So maybe following helps. Try carefully iam no expert in this.

# Wifi Schedule
00 00 * * * /etc/init.d/hostapd stop
00 06 * * * /etc/init.d/hostapd start
1 Like

your suggestion did not work Tulpenknicker,
a workaround that i found was to block internet access on blue thru firewall rule with schedule.
block blue going to red and it works.

it there a reason why your suggestion would not work? would it need a sudo at the beginning or .sh at the end? where can we find hostapd commands for ipfire to test the stop/start? thanks anyway.

Yeah as i wrote iam no expert in this :wink:

If you use in Console

/etc/init.d/hostapd stop

/etc/init.d/hostapd start

this works. So i thought maybe this works also what i wrote

Iam sorry maybe a expert can help here.

You just write two executable scripts with that single commands, put it somewhere on the disk and rely on them in cron.

For stop wifi_stop.sh:

#!/bin/bash
/etc/init.d/hostapd stop

For start wifi_start.sh

#!/bin/bash
/etc/init.d/hostapd start
# Wifi Schedule
00 00 * * * /XXX/wifi_stop.sh
00 06 * * * /XXX/wifi_start.sh

After uploading not to forget making the files executable.

chmod 755 wifi_stop.sh
chmod 755 wifi_start.sh

Cheers, Pierre

1 Like

hi pierre,
thanks for the response. not to sound like an idiot but i have no experience with IPFire. i have dealt with openwrt and it seems different.
in 00 00 * * * /XXX/wifi_stop.sh what would i input for /XXX/.

thanks.

/XXX/ means the exact folder where you placed the files.
For example if you put wifi_stop.sh in the home folder of root, it would look in cron like:

00 00 * * * bash /root/wifi_stop.sh

Pierre

Until today i had no Wifi on my test IPFire. I tried my own suggestion now on my own. Can confirm now myself :wink:

works for me 100%

i am able to execute the hostapd on/off commands manually but cannot get it to work in cron. any suggestions tulpenknicker? i’ve tried thru nano fcrontab -e and wrote as above but no luck. can you paste your location of file. thanks.

All what you have to do is type

fcrontab -e

Scroll down, enter the mentioned data, save. You are done.

As i wrote, works for me.

This works! Can this please be added as a feature request? Tulpenknicker or Pierre? I’m willing to donate if this feature is added to wlan settings. thank you.

I am afraid I can not help you because I am not a dev.