2

I'm trying to write a quick-and-dirty shell script daemon to run on a home router that has a busybox shell, which doesn't support disown. Is there any way to do either of the following?

  • Run a command like command & and then disown it once it's in the background.
  • Run a command "directly" in the background (i.e., not using &).
2

3 Answers 3

0

Since you're the one writing a quick and dirty daemon: let it fork off into the background and let the starting process exit immediately after forking, like any other daemon might.

2
  • The issue is that the daemon itself is a script, so if I can't disown a process from the shell, then neither can the script. Commented Sep 29, 2023 at 21:10
  • @joshlf please edit your question to include that crucial piece of information! A shell script is usually not what people consider a daemon, so that's why I'm a bit surprised :) Commented Sep 29, 2023 at 22:54
0

This sounds like an X Y problem.

Busybox is a very primitive shell, it doesn't support disown.

But why do you want to disown anyway? It's already in the background, and if you exit the shell, busybox isn't going to kill it. The only point of disown is to remove the process from the shell's list of things it is monitoring.

0

Somebody already said this in a comment, but see Detach a process from Sh (not Bash) or “disown” for Sh (not Bash)

TLDR: use nohup command > /dev/null 2>&1 &

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.