How to Run a Command in the background

    • OMV 4.x
    • Resolved
    • table681 wrote:

      Hi,

      So I need to run a mono command from a file so e.g mono file name but my question is where shall i put the file on my server and what shall i type in the file name because it will need the location of the file.

      If you need any more information let me know.

      Thanks
      Okay so I figured out how to run it and cd to the location and everything I have been doing this through shell in a box (web client) however when I run it, it works until I close the tab and then it dies. So I want to know how I can remotely run it so it runs in the background and without having a tab open or anything.

      Cheers

      The post was edited 3 times, last by table681 ().

    • You can run screen in the console window first. Then you can run other commands and they will continue to run even if you close the console window. You can re-attach later using screen -r to see if the commands finished. You can type exit to remove the screen.

      I often use screen. Sometimes in combination with rsync or mc (Midnight Commander) to do big file copying between server.

      linuxize.com/post/how-to-use-linux-screen/
      OMV 4, 7 x ODROID HC2, 1 x ODROID HC1, 5 x 12TB, 1 x 8TB, 1 x 2TB SSHD, 1 x 2TB SSD, GbE, WiFi mesh
    • Adoby wrote:

      You can run screen in the console window first. Then you can run other commands and they will continue to run even if you close the console window. You can re-attach later using screen -r to see if the commands finished. You can type exit to remove the screen.

      I often use screen. Sometimes in combination with rsync or mc (Midnight Commander) to do big file copying between server.

      linuxize.com/post/how-to-use-linux-screen/
      After a few hours of research that what Ive finally come to doing. My question is does a screen last forever (as long as the machine stays on obviously) or will it eventually switch off/die.
    • table681 wrote:

      Adoby wrote:

      You can run screen in the console window first. Then you can run other commands and they will continue to run even if you close the console window. You can re-attach later using screen -r to see if the commands finished. You can type exit to remove the screen.

      I often use screen. Sometimes in combination with rsync or mc (Midnight Commander) to do big file copying between server.

      linuxize.com/post/how-to-use-linux-screen/
      After a few hours of research that what Ive finally come to doing. My question is does a screen last forever (as long as the machine stays on obviously) or will it eventually switch off/die.
      I believe it runs in the background, until you kill the process with either the kill command, reboot, etc. (or some error, etc.. causes it to shut off)
      Air Conditioners are a lot like PC's... They work great until you open Windows.

    • It lasts until you close it. Or reboot.

      If you run a script in it then I think you can end the script with exit and close the screen. But I haven't tried it so I'm not sure. It may just end the script. Perhaps there is a command to exit a screen from a script?

      (Edit: It seems some versions of screen automatically close at the end of a script.
      unix.stackexchange.com/questio…-script-is-done-executing )

      If you often need to run commands or scripts you might want to put them in scripts and have them run automatically at certain times using cron or scheduled jobs in OMV.

      I run daily rsync backups between my OMV servers using scripts started by cron.

      linuxize.com/post/scheduling-cron-jobs-with-crontab/
      OMV 4, 7 x ODROID HC2, 1 x ODROID HC1, 5 x 12TB, 1 x 8TB, 1 x 2TB SSHD, 1 x 2TB SSD, GbE, WiFi mesh

      The post was edited 1 time, last by Adoby ().