How to run a script in background (linux openwrt)?

In OpenWRT there is neither nohup nor screen available by default, so a solution with only builtin commands would be to start a subshell with brackets and put that one in the background with &:

(/root/wget/wget_download.sh >/dev/null 2>&1 )&

you can test this structure easily on your desktop for example with

(notify-send one && sleep 15 && notify-send two)&

... and then close your console before those 15 seconds are over, you will see the commands in the brackets continue execution after closing the console.


The following command will also work:

((/root/wget/wget_download.sh)&)&

This way you don't have to install the 'nohub' command in the tight memory space of the router used for OpenWrt.

I found this somewhere several years ago. It works.

Tags:

Linux

Shell

Ash