Seems like there are better approaches.

In this situation, I would use an epilogue script and give sudo access to the script. Check out https://slurm.schedmd.com/prolog_epilog.html

That would likely be much easier and fit into the methodology slurm uses.

Brian Andrus
Firstspot, Inc.


On 6/4/2018 8:11 AM, Tueur Volvo wrote:
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

2018-06-04 16:36 GMT+02:00 John Hearns <hear...@googlemail.com <mailto:hear...@googlemail.com>>:

    That kinnddd....  of...  defeats...  the.... purpose....  of a job
    scheduler.
    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.

    On 4 June 2018 at 16:15, Tueur Volvo <huitr...@gmail.com
    <mailto:huitr...@gmail.com>> wrote:

        no I don't have dependency treated.

        during the job, I would like to run a program on the machine
        running the job
        but I'd like the program to keep running even after the job ends.

        2018-06-04 15:30 GMT+02:00 John Hearns <hear...@googlemail.com
        <mailto:hear...@googlemail.com>>:

            Tueur what are you trying to achieve here?  The example
            you give istouch /tmp/newfile.txt'
            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'
            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.
            https://hpc.nih.gov/docs/job_dependencies.html
            <https://hpc.nih.gov/docs/job_dependencies.html>

            On 4 June 2018 at 15:20, Tueur Volvo <huitr...@gmail.com
            <mailto:huitr...@gmail.com>> wrote:

                thanks for your answer, i try some solution but it's
                not work

                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)

                        pid_t cpid; //process id's and process groups

                        cpid = fork();

                        if( cpid == 0 ){
                            setsid();
                            setpgrp();
                execl("/bin/sh", "sh", "-c", "sleep 10; reboot1&", NULL);

                        }
                        wait(NULL);


                maybe i have a error in my code ?

                2018-05-31 9:37 GMT+02:00 Yair Yarom
                <ir...@cs.huji.ac.il <mailto:ir...@cs.huji.ac.il>>:

                    Hi,

                    I'm not sure how slurm/spank handles child
                    processes but this might be
                    intentional. So there might be some issues if this
                    were to work.

                    You can try instead of calling system(), to use
                    fork() + exec(). If
                    that still doesn't work, try calling setsid()
                    before the exec(). I can
                    think of situations where your process might still
                    get killed, e.g. if
                    slurm (or even systemd) kills all subprocesses of
                    the "job", by
                    looking at the cgroup. If that's the case, you'll
                    need to move it to
                    another cgroup in addition/instead of setsid().

                        Yair.



                    On Wed, May 30, 2018 at 5:16 PM, Tueur Volvo
                    <huitr...@gmail.com <mailto:huitr...@gmail.com>>
                    wrote:
                    > Hello i have question, how run in background
                    bash script in spank plugin ?
                    >
                    > in my spank plugin in function :
                    slurm_spank_task_init_privileged
                    >
                    > i want to run this script :
                    >
                    > system("nohup bash -c 'sleep 10 ; touch
                    /tmp/newfile.txt' &");
                    >
                    > i want to run in independant process this bash
                    script, i don't want wait 10
                    > seconde in my slurm plugin
                    >
                    > i have this code :
                    > int slurm_spank_task_init_privileged (spank_t
                    sp, int ac, char **av) {
                    >
                    > system("nohup bash -c 'sleep 10 ; touch
                    /tmp/newfile.txt' &");
                    >
                    > return 0;
                    >
                    > }
                    >
                    > actualy it's not work, when slurm ending to run
                    my job, he kill my nohup
                    > command
                    >
                    > if i  had in my c code sleep 12, my bash script work
                    >
                    >
                    > int slurm_spank_task_init_privileged (spank_t
                    sp, int ac, char **av) {
                    >
                    > system("nohup bash -c 'sleep 10 ; touch
                    /tmp/newfile.txt' &");
                    >
                    > sleep(12);
                    >
                    > return 0;
                    >
                    > }
                    >
                    > but i don't want to wait, i want to run my bash
                    script in independant
                    > process
                    >
                    > thanks for advance for your help
                    >
                    >
                    >
                    >







Reply via email to