[slurm-users] run bash script in spank plugin

Yair Yarom irush at cs.huji.ac.il
Thu May 31 01:37:55 MDT 2018


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 <huitre39 at 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
>
>
>
>



More information about the slurm-users mailing list