Helfen Sie mit, Crontab von der Wurzel aus auszuführen

2924
Community

Ich verwende Mac OS X und habe Probleme, einen Cron-Job auszuführen. Ich gebe folgendes ein:

$ sudo -i $ crontab -e 

Ich gebe dann ein:

* * * * * root ifconfig en0 down > /dev/null 0 19 * * * root ifconfig en0 down > /dev/null 0 7 * * * root ifconfig en0 up > /dev/null 

und kein Erfolg, die erste Zeile ist zum Testen. Ich möchte, dass mein Internet abgeschaltet wird. Die nächsten zwei Zeilen, in denen ich vorbeigehen möchte, sobald ich damit fertig bin.

Wenn ich dies in das Terminal eingebe, geht das Internet aus

ifconfig en0 down 

Warum schaltet mein Cronjob das Internet nicht aus?

Zu Ihrer Information: Dies ist eine Folgefrage von Wie schreibe ich einen Cron-Job, der mein Internet von 19 Uhr bis 7 Uhr blockiert? (So ​​kann ich ein wenig schlafen) Die meisten Kommentare gibt es Leute, die sich über mich lustig machen. Und ein paar Versuche, das Problem mit unseren Cron-Jobs zu lösen.

3

2 Antworten auf die Frage

4
WinGuru

Wenn Sie Befehle in Ihre Crontab eingeben, müssen Sie den Benutzer nicht angeben, da für jeden Benutzer eine eigene Crontab in / usr / lib / cron / tabs / gespeichert ist.

Ihr Crontab sollte wie folgt aussehen:
* * * * * /sbin/ifconfig en0 down > /dev/null
0 19 * * * /sbin/ifconfig en0 down > /dev/null
0 7 * * * /sbin/ifconfig en0 up > /dev/null

0
Community

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.