Cornelius Roemer
Cornelius Roemer

Reputation: 8286

How to get exact exit code that a snakemake job exited with?

When a snakemake job errors with a non-zero exit code, snakemake prints:

(one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

Exiting because a job execution failed. Look above for error message

How can I find out what the exact exit code is? I want to know the error code, i.e. 1, 138 etc. with which the job exited.

I'm surprised snakemake doesn't report the exit code explicitly, because explicit is better than implicit.

Upvotes: 2

Views: 75

Answers (1)

Ryan
Ryan

Reputation: 1223

In the documentation, presently here, an example of exiting with a certain non-zero status code is provided, which I have included below. You can probably use similar logic to print out the exit code instead.

shell:
    """
    set +e
    somecommand ...
    exitcode=$?
    if [ $exitcode -eq 1 ]
    then
        exit 1
    else
        exit 0
    fi
    """

For instance, you could output $? to get the exit code.

Upvotes: 2

Related Questions