have R halt the EC2 machine it's running on

后端 未结 4 2029
深忆病人
深忆病人 2021-02-09 01:50

I have a few work flows where I would like R to halt the Linux machine it\'s running on after completion of a script. I can think of two similar ways to do this:

  1. r
4条回答
  •  被撕碎了的回忆
    2021-02-09 02:29

    sudo is an option -- it allows you to run certain commands without prompting for any password. Just put something like this in /etc/sudoers

     ALL=(ALL) PASSWD: ALL, NOPASSWD: /sbin/halt
    

    (of course replacing with the name of user running R) and system('sudo halt') should just work.

提交回复
热议问题