Getting sudo and nohup to work together

后端 未结 9 1665
滥情空心
滥情空心 2021-02-02 06:39

Linux newbie here.

I have a perl script which takes two command line inputs. I tried to run it in the background but this is what I got:

[~user]$ nohup s         


        
9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-02 07:12

    I open an editor and typed these lines:

    #!/bin/bash
    sudo echo Starting ...
    sudo -b MyProcess
    

    (Where MyProcess is anything I want to run as superuser.)

    Then I save the file where I want it as MyShellScript.sh .

    Then change the file permissions to allow execution. Then run it in a terminal. the "-b" option tells sudo to run the process separately in the background, so the process keeps running after the terminal session dies.

    Worked for me in linux-mint.

提交回复
热议问题