# \[SOLVED\] Run a custom script as a cronjob with specific WAN interface?

**URL:** <https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297>\
**Category:** Router\
**Created:** [March 23, 2023, 5:19am UTC](https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297 "2023-03-23T05:19:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![msdos](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@msdos](https://forum.gl-inet.com/u/msdos)\
**Post date:** [March 23, 2023, 5:19am UTC](https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297/1 "2023-03-23T05:19:05Z")

</div>

I’m planning to buy GL-MT3000 to use it’s multi-wan feature with a Huawei E3276 and a 4G chip in my country as a fallback.

I can buy a sms chip of 150GB, but I need to use it at least once in a month or my credits will expire.

I would like to know if it’s possible, by scripting in a cronjob, download everyday a 1mb file from somewhere using this wan. Should I be reading [[OpenWrt Wiki] Write shell scripts in OpenWrt](https://openwrt.org/docs/guide-developer/write-shell-script) and [[OpenWrt Wiki] Scheduling tasks with cron](https://openwrt.org/docs/guide-user/base-system/cron) to accomplish this task?

---

<div class="post-metadata">

**Author:** ![hansome](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/h/b5ac83/32.png) [@hansome](https://forum.gl-inet.com/u/hansome)\
**Post date:** [March 23, 2023, 2:17pm UTC](https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297/2 "2023-03-23T14:17:09Z")

</div>

You can use the curl command to download from certain WAN, from repeater interface:

```auto
curl -I --interface wlan-sta0 http://example.com/file-to-download

```

And integrate this into your shell and crontab configs. That should work.

---

<div class="post-metadata">

**Author:** ![msdos](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@msdos](https://forum.gl-inet.com/u/msdos)\
**Post date:** [March 23, 2023, 6:12pm UTC](https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297/3 "2023-03-23T18:12:45Z")

</div>

Trying in a macbook with a valid interface:

`curl -I --interface en0 https://www.africau.edu/images/default/sample.pdf -O`

Trying with an invalid interface:

```auto
curl -I --interface wlan-sta0 https://www.africau.edu/images/default/sample.pdf -O
curl: (45) Couldn't bind to 'wlan-sta0'
# Returns 1, showing it failed

```

Trying with a valid interface, but offline:

```auto
curl -I --interface en0 https://www.africau.edu/images/default/sample.pdf -O                                                                                                                                         
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: www.africau.edu
# Returns 1, showing it failed

```

It seems robust enough if the curl from openwrt have the --interface feature. I can integrate some logic to correctly monitor this using [https://healthchecks.io](https://healthchecks.io) notifications.

---

<div class="post-metadata">

**Author:** ![msdos](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@msdos](https://forum.gl-inet.com/u/msdos)\
**Post date:** [March 23, 2023, 6:17pm UTC](https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297/4 "2023-03-23T18:17:34Z")

</div>

If somehow curl in openwrt doesn’t have this feature, another solution is to create a script that uses [ubus call](https://openwrt.org/docs/techref/ubus#call). In a script:

- Use ubus call to [call down all interfaces](https://openwrt.org/docs/guide-developer/ubus/network);
- Use ubus call to call up only the 4G interface;
- Download the file;
- Call down all the interfaces and call it up all again.

…or, create a hotplug script (docs/guide-user/base-system/hotplug#iface) that downloads the file and put the commands above in a cron. It depends on preference.

---

<div class="post-metadata">

**Author:** ![anon38652312](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@anon38652312](https://forum.gl-inet.com/u/anon38652312)\
**Post date:** [March 24, 2023, 12:12am UTC](https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297/5 "2023-03-24T00:12:20Z")

</div>

This is currently working on the Slate and used for speed test: [SmoothWAN-feeds/wanspeedtest at main · SmoothWAN/SmoothWAN-feeds · GitHub](https://github.com/SmoothWAN/SmoothWAN-feeds/blob/main/speedifyconf/net/usr/bin/wanspeedtest)

---

<div class="post-metadata">

**Author:** ![bruce](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/bruce/32/35649_2.png) [@bruce](https://forum.gl-inet.com/u/bruce)\
**Post date:** [October 29, 2025, 4:21am UTC](https://forum.gl-inet.com/t/solved-run-a-custom-script-as-a-cronjob-with-specific-wan-interface/28297/6 "2025-10-29T04:21:22Z")

</div>


