Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 http://superuser.com/questions/152122/how-can-i-write-a-cron-job-that-will-block-my-internet-from-7pm-to-7am-so-i-can most of the comments there are people making fun of me. And a few attempts to solve the problem with out cron jobs.

share|improve this question

migrated from stackoverflow.com Jun 13 '10 at 0:48

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.