Getting sudo and nohup to work together

后端 未结 9 1640
滥情空心
滥情空心 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:23

    The problem here, imho, is not nohup, but background processing sudo.

    You are putting the process in background (& at end of command) but probably sudo needs password authentication, and that is why the process stops.

    Try one of these:

    1) remove the ampersand from end of command, reply to passord prompt and afterwords put it in background (by typing CTRL-Z - which stops the process and issuing the bg command to send it to background)

    2) Change the /etc/sudoers to not ask for users password by including the line: myusername ALL=(ALL) NOPASSWD: ALL

    If besides the password reply your application waits for other input, then you can pipe the input to the command like this: $ cat responses.txt|sudo mycommand.php

    hth

提交回复
热议问题