Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions shelper/squeue.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
// All rights reserved.
package shelper

import (
"bytes"
"fmt"
"os/exec"
)

// GetSlurmJobIDsSqueue queries slurmctld for the job ids of all jobs running on this host, it returns a comma separated string of job ids.
func GetSlurmJobIDsSqueue() ([]string, error) {
hostname, err := GetHostname()
jobIDs := []string{}

if err != nil {
return jobIDs, err
}
// -h: remove slurm headers from output
// -w <hostname>: only get jobs running on the given host
// -o <field>: output only the given field
// %i: job id
cmd := exec.Command("squeue", "-h", "-w", hostname, "-o", "%i")

var out bytes.Buffer
cmd.Stdout = &out

var stderr bytes.Buffer
cmd.Stderr = &stderr

cmdErr := cmd.Run()
if cmdErr != nil {
err = fmt.Errorf("%w: %v", cmdErr, stderr.String())
return jobIDs, err
}

jobIDs = parseNewLineToList(out.String())
return jobIDs, nil
}
Loading