Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Using Automator to turn off wifi (with timer)

I need to get my internet browsing and email checking under control so I can focus on writing my thesis. I've considered an app like "Freedom" http://macfreedom.com/. However it seems there should be a way to use Automator for easily turning off / blocking my wi-fi connection for set amounts of time - e.g. two hours.


Ideally it would also start a timer app like "BeHealthy" http://itunes.apple.com/us/app/behealthy/id442127171?mt=12


I have never used Automator before so the process is a bit daunting. Any advice is appreciated.

MacBook Air, Mac OS X (10.7.4)

Posted on Jul 5, 2012 10:05 AM

Reply
11 replies

Jul 5, 2012 10:38 AM in response to ethnoguy

If you happen to be using a Wi-Fi network with an Apple Airport of Time Capsule as your wireless router you can use the Airport Configuration Utility to only allow certain computers to use the network on a certain schedule.


(other brands of wireless routers may allow this functionality as well)


That would effectilvely keep you off the internet and email but otherwise with full access to the computer.


Matt

Jul 5, 2012 6:12 PM in response to BobHarris

For some reason the script doesn't seem to work. The little cog turns on the bar but the wireless indicator stays on and I can still surf. It gives an error message "The action “Run Shell Script” encountered an error."


Note: I just wanted to test for 100 sec so I change to "sleep 100". (I do not have a Time Capsule just the wireless receiver built into the Macbook Air with a non-apple wireless router.)


Short of just turning off the router is their another sollution?

Jul 6, 2012 8:17 AM in response to ethnoguy

I have tested the script and it does work for me.


OK, just looked at what Mac your signature says you are using (Macbook Air) which does not have an en0 ethernet port and en1 WiFi. Rather your Macbook Air most likely "Just" has an en0 WiFi port.


Using Applications -> Utilities -> Network Utility -> Info -> Select a network interface for information


Does it say "Wi-Fi (en0)" or "Wi-Fi (en1)"?


Anyway, change the script from using en1 to using whatever Network Utility says is your WiFi device.

Jul 6, 2012 12:15 PM in response to ethnoguy

Rude and crude


/usr/sbin/networksetup -setairportpower en0 off

n=120
while [[ $n -gt 0 ]]
do
    echo "$n minutes until Airport WiFi turned back on" >$HOME/Airport_Off_Time_Remaining.txt
    sleep 60
    n=$((n-1))
done

/usr/sbin/networksetup -setairportpower en0 on


Now when you want to see how much time is left, you double click on Airport_Off_Time_Remaining.txt in your Home Folder. You will have to close the TextEdit window each time and re-open the Airport_Off_Time_Remaining.txt each time. I said this was "Rude and Crude" 🙂

Nov 22, 2015 4:30 PM in response to BobHarris

Hi Bob,


Thanks for the drill down on the WiFi setting on the Automator. I had a similar question and thought you might be able to help me too. I want to set my Wifi to automatically turn off after 6pm M-F and come on again at 8am. I also want my WiFi to stay off during the weekend Sa-Su. Ideally, if I need to use my work computer during that time, I would just wake up my iMac (click trackpad) and just enable the WiFi again manually (WiFi icon > Turn on WiFi).


Thanks again for any assistance you can offer.


Best,

Nathan

Nov 23, 2015 5:09 AM in response to OhGreat

OhGreat wrote:

Thanks for the drill down on the WiFi setting on the Automator. I had a similar question and thought you might be able to help me too. I want to set my Wifi to automatically turn off after 6pm M-F and come on again at 8am. I also want my WiFi to stay off during the weekend Sa-Su. Ideally, if I need to use my work computer during that time, I would just wake up my iMac (click trackpad) and just enable the WiFi again manually (WiFi icon > Turn on WiFi).

Create 2 automator apps. One that turns WiFi off, and one that turns WiFi on (adjust the en0, en1 values as appropriate for your Mac).


Now create a calendar action for 6pm M-F that invokes the turn off app and a M-F 8am action to run the turn on app. Since the Friday turn off action will not be countered until Monday, you get no WiFi all weekend as a side effect.

<http://www.macissues.com/2014/07/17/easily-schedule-tasks-with-calendar-in-os-x/>


You could also do this via a launch agent or launch daemon, but that is more complicated, and calendar events are easier to setup.

<http://www.thesafemac.com/scheduling-recurring-tasks/>

Using Automator to turn off wifi (with timer)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.