Posts

Ubuntu background running a ./sh file

Image
  If you need to run your ./app.sh script in the background and ensure it continues running after you close the terminal, without manually detaching from a session as required by screen or tmux , you can combine nohup with & and then immediately exit the terminal. This approach is suitable if you're running a command via SSH and want to close the session right after starting the command, or if you're scripting the execution and termination process. Here's how you can do it: sh Copy code nohup ./app.sh > app.log 2>&1 & Breaking down the command: nohup ensures that the command doesn't receive the hangup signal when the terminal is closed. ./app.sh is your script you want to run in the background. > app.log redirects standard output (stdout) to a file named app.log , so you won't lose your output after the terminal is closed. 2>&1 redirects standard error (stderr) to standard output (stdout), which means both output and errors go to...