# Best way to autostart a script with network delay after login?

**URL:** <https://forum.maboxlinux.org/t/best-way-to-autostart-a-script-with-network-delay-after-login/2294>\
**Category:** Basic Help & Support\
**Created:** [July 16, 2025, 9:53pm UTC](https://forum.maboxlinux.org/t/best-way-to-autostart-a-script-with-network-delay-after-login/2294 "2025-07-16T21:53:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhonnmick](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/jhonnmick/32/3947_2.png) [@jhonnmick](https://forum.maboxlinux.org/u/jhonnmick)\
**Post date:** [July 16, 2025, 9:53pm UTC](https://forum.maboxlinux.org/t/best-way-to-autostart-a-script-with-network-delay-after-login/2294/1 "2025-07-16T21:53:24Z")

</div>

Hi Mabox community,

I’m trying to set up a custom script that runs on login, but only after the network is fully up (I’m syncing a few dotfiles from a private Git repo).

I added the script to my Openbox autostart, but it sometimes runs before Wi-Fi connects, which causes it to fail.

Any suggestions for a lightweight way to delay execution until the system confirms an active network connection? Maybe using nmcli or something in the Mabox [toolkit](https://calculadoradedias.com/cumpleanos/)?

Appreciate any tips or examples!

— Jhonn Mick

---

<div class="post-metadata">

**Author:** ![napcok](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/napcok/32/410_2.png) [@napcok](https://forum.maboxlinux.org/u/napcok)\
**Post date:** [July 16, 2025, 10:10pm UTC](https://forum.maboxlinux.org/t/best-way-to-autostart-a-script-with-network-delay-after-login/2294/2 "2025-07-16T22:10:04Z")

</div>

Hello @jhonnmick and welcome to the forum 🙂

I would try something like:

```auto
(sleep 10s && myscript) &

```

at the very end of the `~/.config/openbox/autostart` file.

---

<div class="post-metadata">

**Author:** ![jhonnmick](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/jhonnmick/32/3947_2.png) [@jhonnmick](https://forum.maboxlinux.org/u/jhonnmick)\
**Post date:** [July 16, 2025, 10:22pm UTC](https://forum.maboxlinux.org/t/best-way-to-autostart-a-script-with-network-delay-after-login/2294/3 "2025-07-16T22:22:01Z")

</div>

Thanks @napcok

I ended up using a simple loop with `nmcli` to check for an active connection before running the script. Added this to my autostart instead of calling the sync script directly:

```auto
while ! nmcli -t -f STATE g | grep -q "connected"; do
  sleep 2
done
~/.config/scripts/sync-dotfiles.sh

```

It’s lightweight, reliable, and does exactly what I needed. Appreciate your support!

— Jhonn Mick
