Help with running crontab from root
I'm using Mac OS X and having trouble getting a cron job to run. I type the following:
$ sudo -i $ crontab -e
I then enter:
* * * * * root ifconfig en0 down > /dev/null 0 19 * * * root ifconfig en0 down > /dev/null 0 7 * * * root ifconfig en0 up > /dev/null
and no success, the first line is for testing. I want it to shut off my internet. The next two lines I plan to leave in, once I get this working.
If I type this in to the terminal the internet goes off
ifconfig en0 down
Why is my cron job not shutting down the internet?
FYI: This is a follow up question from How can I write a cron job that will block my internet from 7pm to 7am? (So I can get some sleep) most of the comments there are people making fun of me. And a few attempts to solve the problem with out cron jobs.
When you enter commands in your crontab, you don't need to specify the user, as each user has their own individual crontab stored in /usr/lib/cron/tabs/
Your crontab should look like the following: * * * * * /sbin/ifconfig en0 down > /dev/null 0 19 * * * /sbin/ifconfig en0 down > /dev/null 0 7 * * * /sbin/ifconfig en0 up > /dev/null
Do you have a wifi router, and your airport still open? If so, you need to shut that off as well. Either shut it off permanently though System Preferences -> Networking, or use cron commands to do the same. On my machine the Airport is en1, but I've explained how to check in an answer to your original question if you're not sure.
Another thing to check is the path at the top of the crontab file. It must provide access to the ifconfig command.
Run 'whereis ifconfig' on the terminal to find out where the ifconfig command is located, and add that path to the path command at the top of the crontab file if it's not there.