How to Run a Command in the background

  • 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

    3 Mal editiert, zuletzt von table681 ()

    • Offizieller Beitrag

    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.


    https://linuxize.com/post/how-to-use-linux-screen/

  • 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.


    https://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.

    • Offizieller Beitrag

    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)

    • Offizieller Beitrag

    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.
    https://unix.stackexchange.com…-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.


    https://linuxize.com/post/scheduling-cron-jobs-with-crontab/

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!