Search code examples
cluster-computinghpcslurm

How to retrieve the content of slurm script?


I submitted a job several days ago, and it is still running now. But I forget the content of that script.sh that day. And the script.sh has been deleted. Do you know how to recover the content of that script?


Solution

  • With recent versions, you can retrieve the job script for your own jobs with

    scontrol write batch_script <job_id> <optional_filename>
    

    From the man page:

    Write the batch script for a given job_id to a file or to stdout. The file will default to slurm-<job_id>.sh if the optional filename argument is not given. The script will be written to stdout if - is given instead of a filename. The batch script can only be retrieved by an admin or operator, or by the owner of the job.

    On older versions, the write batch_script command does not exist, but you can get the script with

    scontrol show -ddd job <job_id>