LEDE/OpenWRT — Scheduling Tasks

Automating certain tasks on your LEDE/OpenWRT device can help keep things running smoothly.

In this example we are going to show you how to use Cron to disable your WiFi at 11:30pm, and reboot at 6:30am.

SSH to your LEDE/OpenWRT device

If you are using Windows then start PuTTY and click Session on the left side, select SSH from the options, and then enter in the IP Address of your LEDE/OpenWRT box into the Host Name field.

Once you’ve done this just click on Open to start up the SSH connection.

PuTTY

If you are connecting via terminal, then just SSH to your LEDE/OpenWRT device using the following command, where 192.168.1.1 is your LEDE/OpenWRT device’s IP address.

ssh root@192.168.1.1

Setting up your timezone

First you’re going to need to make sure you have your timezone set up correctly on your device.

Run the following command:

vi /etc/config/system

You should see something like the following, where UTC is the default timezone:

config ‘system’ 
option ‘hostname’ ‘OpenWrt’
option ‘timezone’ ‘UTC’

Replace UTC with the respective timezone code for your desired timezone. You can find a list of all the supported timezones here.

Creating your Cron

By default Cron is not enabled, so first up you need to change this.

Run the following command to enable Cron:

/etc/init.d/cron enable

Now that Cron is enabled, run the following command to edit the cron config:

crontab -e

Now enter in the following:

30 23 * * * wifi down
30 06 * * * reboot

The first line runs wifi down at 23:30 every day, which disables the WiFi.

The second line runs a reboot at 6:30 every day, which reboots the device to clear used memory which in turn brings the WiFi back up again.

You can find more information on different time combinations on the OpenWRT Wiki here.

Finally we just need to start the cron process, which we can do by entering the following command:

/etc/init.d/cron start

If you found this post helpful please let us know by clicking the ♥ below.

This blog was brought to you by Cucumber Wi-Fi. Cucumber helps you run a more efficient Wi-Fi network. Check it out here.

Cucumber Wi-Fi — control any (Wi-Fi) device from the cloud.

Show your support

Clapping shows how much you appreciated CT WiFi’s story.