<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Seems like there are better approaches.</p>
    <p>In this situation, I would use an epilogue script and give sudo
      access to the script. Check out
      <a class="moz-txt-link-freetext" href="https://slurm.schedmd.com/prolog_epilog.html">https://slurm.schedmd.com/prolog_epilog.html</a></p>
    <p>That would likely be much easier and fit into the methodology
      slurm uses.</p>
    <p>Brian Andrus<br>
      Firstspot, Inc.<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 6/4/2018 8:11 AM, Tueur Volvo wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAHLw0S8sb44hKzsUcKk5k=5L3tyyofua9h=41WaYooHKB5HKfw@mail.gmail.com">
      <div dir="ltr">I would like to run a bash script or binary
        executable as root (even if the user who started the job doesn't
        have root rights) at the end of a job if I put an option in my
        spank plugin<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2018-06-04 16:36 GMT+02:00 John Hearns
          <span dir="ltr"><<a href="mailto:hearnsj@googlemail.com"
              target="_blank" moz-do-not-send="true">hearnsj@googlemail.com</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div>That kinnddd....  of...  defeats...  the....
                purpose....  of a job scheduler.</div>
              <div>I am very sure that you know why you need this and
                you have a good reason for doing it.  Over to others on
                the list, sorry.<br>
              </div>
            </div>
            <div class="HOEnZb">
              <div class="h5">
                <div class="gmail_extra"><br>
                  <div class="gmail_quote">On 4 June 2018 at 16:15,
                    Tueur Volvo <span dir="ltr"><<a
                        href="mailto:huitre39@gmail.com" target="_blank"
                        moz-do-not-send="true">huitre39@gmail.com</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      <div dir="ltr">no I don't have dependency treated.<br>
                        <br>
                        during the job, I would like to run a program on
                        the machine running the job<br>
                        but I'd like the program to keep running even
                        after the job ends.<br>
                      </div>
                      <div class="m_6112803144883790435HOEnZb">
                        <div class="m_6112803144883790435h5">
                          <div class="gmail_extra"><br>
                            <div class="gmail_quote">2018-06-04 15:30
                              GMT+02:00 John Hearns <span dir="ltr"><<a
                                  href="mailto:hearnsj@googlemail.com"
                                  target="_blank" moz-do-not-send="true">hearnsj@googlemail.com</a>></span>:<br>
                              <blockquote class="gmail_quote"
                                style="margin:0 0 0 .8ex;border-left:1px
                                #ccc solid;padding-left:1ex">
                                <div dir="ltr">
                                  <div>Tueur what are you trying to
                                    achieve here?  The example you give
                                    is<span
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244gmail-m_-2665505057655900136gmail-s">          
                                      touch /tmp/newfile.txt' <br>
                                    </span></div>
                                  <div><span
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244gmail-m_-2665505057655900136gmail-s">I
                                      think you are trying to send a
                                      signal to another process. Could
                                      this be 'Hey - the job has
                                      finished and there is a new file
                                      for you to process'</span></div>
                                  <div><span
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244gmail-m_-2665505057655900136gmail-s">If
                                      that is so, there may be better
                                      ways to do this. If you have a
                                      post-processing step, then you can
                                      submit a job whihc depends on the
                                      main job.</span></div>
                                  <div><span
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244gmail-m_-2665505057655900136gmail-s"><a
href="https://hpc.nih.gov/docs/job_dependencies.html" target="_blank"
                                        moz-do-not-send="true">https://hpc.nih.gov/docs/job_d<wbr>ependencies.html</a><br>
                                    </span></div>
                                </div>
                                <div
                                  class="m_6112803144883790435m_-6743702450101823989HOEnZb">
                                  <div
                                    class="m_6112803144883790435m_-6743702450101823989h5">
                                    <div class="gmail_extra"><br>
                                      <div class="gmail_quote">On 4 June
                                        2018 at 15:20, Tueur Volvo <span
                                          dir="ltr"><<a
                                            href="mailto:huitre39@gmail.com"
                                            target="_blank"
                                            moz-do-not-send="true">huitre39@gmail.com</a>></span>
                                        wrote:<br>
                                        <blockquote class="gmail_quote"
                                          style="margin:0 0 0
                                          .8ex;border-left:1px #ccc
                                          solid;padding-left:1ex">
                                          <div dir="ltr">
                                            <div>thanks for your answer,
                                              i try some solution but
                                              it's not work</div>
                                            <div><br>
                                            </div>
                                            <div>i try to add setsid and
                                              setpgrp for isolate my new
                                              process but slurm job
                                              sleep 6secondes and reboot
                                              my machine (i test with
                                              reboot command, but we can
                                              make other bash command,
                                              it's just example)</div>
                                            <div><br>
                                            </div>
                                            <div>        pid_t cpid;
                                              //process id's and process
                                              groups<br>
                                              <br>
                                                      cpid = fork();<br>
                                              <br>
                                                      if( cpid == 0 ){<br>
                                                          setsid();<br>
                                                          setpgrp();<br>
                                                         
                                              execl("/bin/sh", "sh",
                                              "-c", "sleep 10;
                                              reboot1&", NULL);<br>
                                                          <br>
                                                      }<br>
                                                      wait(NULL);</div>
                                            <div><br>
                                            </div>
                                            <div><br>
                                            </div>
                                            <div>maybe i have a error in
                                              my code ?<br>
                                            </div>
                                          </div>
                                          <div
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244HOEnZb">
                                            <div
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244h5">
                                              <div class="gmail_extra"><br>
                                                <div class="gmail_quote">2018-05-31
                                                  9:37 GMT+02:00 Yair
                                                  Yarom <span dir="ltr"><<a
href="mailto:irush@cs.huji.ac.il" target="_blank" moz-do-not-send="true">irush@cs.huji.ac.il</a>></span>:<br>
                                                  <blockquote
                                                    class="gmail_quote"
                                                    style="margin:0 0 0
                                                    .8ex;border-left:1px
                                                    #ccc
                                                    solid;padding-left:1ex">Hi,<br>
                                                    <br>
                                                    I'm not sure how
                                                    slurm/spank handles
                                                    child processes but
                                                    this might be<br>
                                                    intentional. So
                                                    there might be some
                                                    issues if this were
                                                    to work.<br>
                                                    <br>
                                                    You can try instead
                                                    of calling system(),
                                                    to use fork() +
                                                    exec(). If<br>
                                                    that still doesn't
                                                    work, try calling
                                                    setsid() before the
                                                    exec(). I can<br>
                                                    think of situations
                                                    where your process
                                                    might still get
                                                    killed, e.g. if<br>
                                                    slurm (or even
                                                    systemd) kills all
                                                    subprocesses of the
                                                    "job", by<br>
                                                    looking at the
                                                    cgroup. If that's
                                                    the case, you'll
                                                    need to move it to<br>
                                                    another cgroup in
                                                    addition/instead of
                                                    setsid().<br>
                                                    <span
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244m_1370820081454262057HOEnZb"><font
                                                        color="#888888"><br>
                                                            Yair.<br>
                                                      </font></span>
                                                    <div
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244m_1370820081454262057HOEnZb">
                                                      <div
class="m_6112803144883790435m_-6743702450101823989m_-11226471504385244m_1370820081454262057h5"><br>
                                                        <br>
                                                        <br>
                                                        On Wed, May 30,
                                                        2018 at 5:16 PM,
                                                        Tueur Volvo <<a
href="mailto:huitre39@gmail.com" target="_blank" moz-do-not-send="true">huitre39@gmail.com</a>>
                                                        wrote:<br>
                                                        > Hello i
                                                        have question,
                                                        how run in
                                                        background bash
                                                        script in spank
                                                        plugin ?<br>
                                                        ><br>
                                                        > in my spank
                                                        plugin in
                                                        function :
                                                        slurm_spank_task_init_privileg<wbr>ed<br>
                                                        ><br>
                                                        > i want to
                                                        run this script
                                                        :<br>
                                                        ><br>
                                                        >
                                                        system("nohup
                                                        bash -c 'sleep
                                                        10 ; touch
                                                        /tmp/newfile.txt'
                                                        &");<br>
                                                        ><br>
                                                        > i want to
                                                        run in
                                                        independant
                                                        process this
                                                        bash script, i
                                                        don't want wait
                                                        10<br>
                                                        > seconde in
                                                        my slurm plugin<br>
                                                        ><br>
                                                        > i have this
                                                        code :<br>
                                                        > int
                                                        slurm_spank_task_init_privileg<wbr>ed
                                                        (spank_t sp, int
                                                        ac, char **av) {<br>
                                                        ><br>
                                                        >
                                                        system("nohup
                                                        bash -c 'sleep
                                                        10 ; touch
                                                        /tmp/newfile.txt'
                                                        &");<br>
                                                        ><br>
                                                        > return 0;<br>
                                                        ><br>
                                                        > }<br>
                                                        ><br>
                                                        > actualy
                                                        it's not work,
                                                        when slurm
                                                        ending to run my
                                                        job, he kill my
                                                        nohup<br>
                                                        > command<br>
                                                        ><br>
                                                        > if i  had
                                                        in my c code
                                                        sleep 12, my
                                                        bash script work<br>
                                                        ><br>
                                                        ><br>
                                                        > int
                                                        slurm_spank_task_init_privileg<wbr>ed
                                                        (spank_t sp, int
                                                        ac, char **av) {<br>
                                                        ><br>
                                                        >
                                                        system("nohup
                                                        bash -c 'sleep
                                                        10 ; touch
                                                        /tmp/newfile.txt'
                                                        &");<br>
                                                        ><br>
                                                        > sleep(12);<br>
                                                        ><br>
                                                        > return 0;<br>
                                                        ><br>
                                                        > }<br>
                                                        ><br>
                                                        > but i don't
                                                        want to wait, i
                                                        want to run my
                                                        bash script in
                                                        independant<br>
                                                        > process<br>
                                                        ><br>
                                                        > thanks for
                                                        advance for your
                                                        help<br>
                                                        ><br>
                                                        ><br>
                                                        ><br>
                                                        ><br>
                                                        <br>
                                                      </div>
                                                    </div>
                                                  </blockquote>
                                                </div>
                                                <br>
                                              </div>
                                            </div>
                                          </div>
                                        </blockquote>
                                      </div>
                                      <br>
                                    </div>
                                  </div>
                                </div>
                              </blockquote>
                            </div>
                            <br>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>