Public course previewThis is not your assigned passport. No identity, answers, or completion progress are stored here.How to start your passport
Guided lesson
03 / 06About 35 minutesuses shared Euler resources

Submit And Control A Tiny Euler CPU Job

Follow one tiny CPU job from an inspected script to its recorded result and output.

Where you will workOn your computer first, then on the remote Euler computer
  1. 1Understand
  2. 2Try it yourself
  3. 3Check and submit

Before you start#

Euler has login nodes and compute nodes. Prepare files and control jobs from the login node. Slurm is the scheduler; it runs actual computation on a compute node. A batch job is a submitted script, not merely a file in a folder. sbatch submits one batch script and returns its job ID. Keep that number in $HOME, your small private Euler folder, and use the same numeric job ID later.

Stage What you inspect What it establishes
Create and inspect Script text and syntax result The file is ready, not running
Submit once Returned numeric ID Slurm accepted that submission
Observe squeue for that ID Whether it is currently queued or running
Read the result sacct, seff and its output Recorded state, resources and expected calculation

GiB is the memory unit used here. The teaching request is one CPU, 1 GiB per CPU, two minutes, no GPU and the already verified Euler Python environment. This is a workflow test, not a resource recommendation for a research program.

If the script prints correctly but the queue is empty, what has actually happened so far? Decide which stage you reached before trying another command. The recipe follows one job throughout; you do not need a second submission.

Read the completed job without mixing its rows
Form observation Where to compare it
Account Main row: normal/es_fuge or es_fuge; normal/es+ is truncated
State and exit code Main row: COMPLETED and 0:0
CPU and requested memory Main row: one CPU and 1G (per-CPU suffix may appear)
Observed memory Relevant .batch step; not the requested value
Program output Same ID: python_environment=passport-python and 5 squared is 25

Read seff for that same job. Keep actual logs and identifiers private; enter only the requested observations in the local form.

Submitting again because a short job disappeared from the queue. Keep the stored ID and read its accounting and logs; queue visibility is not its outcome.

Start the practice

Practice

Follow the steps

Follow in order

Steps

Run every Euler command on the same login node. The recipe stores one job ID in $HOME/passport-euler/first-job.id so it survives logout; never resubmit because a job is pending.

Optional: using the terminal

A command is a line of text that tells a computer to do one task. You paste it into a terminal, the text application used for commands. A shell is the part inside that application that reads the command. PowerShell, zsh, and Bash are shells. Open only the application named for your computer below; it starts its configured shell. Follow the shell named below. You do not need to install a separate Bash or zsh application.

Your computer or local means the laptop or desktop in front of you. Remote means another computer reached through the network. A command affects whichever computer the step names, so check that label before pasting.

  • Windows: press the Windows key, type PowerShell, and open the result named PowerShell. Do not use Command Prompt, Git Bash, or WSL for a block labelled PowerShell.
  • macOS: press Command+Space, type Terminal, and press Return. Terminal normally starts the zsh shell. If it uses another shell, run zsh for this session.
  • Linux: open the app named Terminal from the applications menu. It normally starts the Bash shell. If it uses another shell, run bash for this session.

The prompt is the text beside the blinking cursor. For each card, check the named computer, choose Copy, paste only the command after the prompt, press Enter once, and wait for the prompt to return.

If you have never done this before, first run the harmless terminal-ready practice on the start page. It lets you practise copying, pasting, pressing Enter, and reading output before a setup command.

Practise one harmless command first

Euler card: Euler is ETH Zurich's service made of many managed computers for research calculations. SSH is the protected connection that opens a Bash shell on Euler in the same terminal window. Connect first, then run the card there, not on your laptop.

How to open a terminal and run a command
  1. 01

    Know where an Euler job runs

    Read and answer on this web page

    Follow the four stages in the lifecycle above. Before connecting, distinguish preparing a file from asking Slurm to run it. Keep the same numeric job ID for every observation after submission.

    Look forYou can distinguish the login node from the compute node and state what sbatch, squeue, sacct, and seff do.

    Explanation and help
    What this means
    Connect to the login node.
    Safe recovery
    Do not run a workload until the login-node and compute-node roles are clear.
  2. 02

    Connect to Euler

    On your computer

    From your local terminal, connect with the tested euler alias. The prompt should change to an Euler login node.

    RunPowerShell on Windows
    ssh euler
    RunTerminal on macOS (zsh)
    ssh euler
    RunTerminal on Linux (Bash)
    ssh euler

    Look forThe shell prompt is on an Euler login node.

    If this differsReturn to the SSH mission; do not use password fallback as a tunnel workaround.

    Explanation and help
    What this means
    Confirm the login-node context and lab share.
  3. 03

    Confirm the login node and account

    Use Euler after you connect from your computer

    Run these read-only checks on Euler before creating a job. The host must be a login node and my_share_info must list es_fuge.

    RunThis text window after SSH connects to Euler
    hostname
    my_share_info

    Look forThe hostname is an Euler login node and es_fuge appears in your share information.

    If this differsStop if es_fuge is absent. Do not guess another account; use the access help path.

    Explanation and help
    What this means
    Create the small job script.
  4. 04

    Create and inspect the job script

    Use Euler after you connect from your computer

    Paste the whole creation block, including EOF and the final closing parenthesis. It creates or safely reuses the training script, checks its syntax and prints it; it does not run the calculation. Compare its CPU, memory, time, account, environment and log directives with the small teaching request above before submitting.

    RunThis text window after SSH connects to Euler
    (
    set -eu
    work_dir="$HOME/passport-euler"
    script="$work_dir/first-job.slurm"
    mkdir -p "$work_dir/logs"
    tmp="$(mktemp "$work_dir/.first-job.XXXXXX")"
    trap 'if [ -n "${tmp:-}" ]; then rm -f "$tmp"; fi' EXIT
    cat > "$tmp" <<'EOF'
    #!/usr/bin/env bash
    #SBATCH --job-name=passport-cpu
    #SBATCH --account=es_fuge
    #SBATCH --time=00:02:00
    #SBATCH --ntasks=1
    #SBATCH --cpus-per-task=1
    #SBATCH --mem-per-cpu=1G
    #SBATCH --output=logs/%x_%j.out
    #SBATCH --error=logs/%x_%j.err
    
    set -euo pipefail
    module purge
    module load stack/2024-06 python/3.11.6
    venv="$HOME/passport-euler/venvs/passport-python"
    [ -x "$venv/bin/python" ] || {
      printf 'STOP: complete the Euler Python environment mission first.\n' >&2
      exit 1
    }
    . "$venv/bin/activate"
    python - <<'PYTHON'
    import os
    import pathlib
    import platform
    import socket
    import sys
    
    expected = pathlib.Path.home() / "passport-euler" / "venvs" / "passport-python"
    if pathlib.Path(sys.prefix) != expected or platform.python_version() != "3.11.6":
        raise SystemExit("STOP: unexpected Python environment")
    print(f"job_id={os.environ['SLURM_JOB_ID']}")
    print(f"host={socket.gethostname()}")
    print(f"cpus={os.environ['SLURM_CPUS_PER_TASK']}")
    print("python_environment=passport-python")
    for number in range(1, 6):
        print(f"{number} squared is {number * number}")
    PYTHON
    EOF
    if [ -e "$script" ]; then
      cmp -s "$tmp" "$script" || {
        printf 'STOP: %s already exists with different content.\n' "$script" >&2
        exit 1
      }
      printf 'existing-script-ok\n'
    else
      mv "$tmp" "$script"
      tmp=''
      printf 'created-script-ok\n'
    fi
    cd "$work_dir"
    bash -n first-job.slurm
    sed -n '1,100p' first-job.slurm
    )

    Look forcreated-script-ok or existing-script-ok, followed by script text ending at PYTHON. EOF and the following creation-command lines are not printed as part of the script. No job was submitted here; an empty queue is normal.

    If this differsCorrect the script before sbatch; do not submit a script you have not read.

    Explanation and help
    What this means
    After checking the script, use Step 5 to submit it once.
  5. 05

    Submit once and record the job ID

    Use Euler after you connect from your computer

    Submit only when no stored job ID exists. If this step was already completed, the command reuses the stored numeric ID and does not submit another job.

    RunThis text window after SSH connects to Euler
    (
    set -eu
    cd "$HOME/passport-euler"
    id_file="$HOME/passport-euler/first-job.id"
    if [ -e "$id_file" ]; then
      [ -s "$id_file" ] || { printf 'STOP: %s is empty. Ask for help before submitting.\n' "$id_file" >&2; exit 1; }
      job_id="$(cat "$id_file")"
      case "$job_id" in ''|*[^0-9]*) printf 'STOP: stored job ID is invalid.\n' >&2; exit 1;; esac
      printf 'Existing job, not resubmitted: %s\n' "$job_id"
    else
      submission="$(sbatch --parsable first-job.slurm)"
      job_id="${submission%%;*}"
      case "$job_id" in ''|*[^0-9]*) printf 'STOP: sbatch did not return a numeric job ID.\n' >&2; exit 1;; esac
      printf '%s\n' "$job_id" > "$id_file"
      chmod 600 "$id_file"
      printf 'Submitted job: %s\n' "$job_id"
    fi
    )

    Look forOne numeric job ID is printed and stored, including on clusters where sbatch appends a cluster name; rerunning the step says Existing job, not resubmitted.

    If this differsRead the sbatch error and fix its cause; do not submit a second copy.

    Explanation and help
    What this means
    Inspect that job in the queue.
  6. 06

    Inspect the queue

    Use Euler after you connect from your computer

    Query only the recorded job. No row means it is not currently visible in the active queue; accounting and logs establish what happened. Keep its ID and do not submit a duplicate.

    RunThis text window after SSH connects to Euler
    (
    job_id="$(cat "$HOME/passport-euler/first-job.id")"
    case "$job_id" in ''|*[^0-9]*) printf 'STOP: stored job ID is invalid.\n' >&2; exit 1;; esac
    squeue -j "$job_id" -o "%.18i %.2t %.30R"
    )

    Look forThe job is pending or running, or it has already left the queue.

    If this differsIf the ID is wrong, recover it with squeue -u "$USER" or sacct; do not resubmit.

    Explanation and help
    What this means
    Read accounting for that same ID. If the request is wrong and must be stopped, use the optional cancellation section; do not cancel a successful job merely for practice.
  7. 07

    Verify completion with sacct

    Use Euler after you connect from your computer

    Run this for the same job. If it says job-not-finished, wait 30 seconds and run this same step again. Never return to sbatch while waiting.

    RunThis text window after SSH connects to Euler
    (
    set -eu
    job_id="$(cat "$HOME/passport-euler/first-job.id")"
    case "$job_id" in ''|*[^0-9]*) printf 'STOP: stored job ID is invalid.\n' >&2; exit 1;; esac
    state="$(sacct -X -n -j "$job_id" --format=State | awk 'NF {print $1; exit}' | cut -d+ -f1)"
    case "$state" in
      COMPLETED) printf 'job-completed\n' ;;
      PENDING|RUNNING|CONFIGURING|COMPLETING) printf 'job-not-finished: %s; wait 30 seconds and rerun this step; do not resubmit\n' "$state"; exit 2 ;;
      '') printf 'accounting-not-ready; wait 30 seconds and rerun this step; do not resubmit\n'; exit 2 ;;
      *) printf 'STOP: job ended in %s; inspect both logs before changing resources.\n' "$state" >&2; sacct -j "$job_id" --format=JobID,JobName,User,Account%40,State,ExitCode,Elapsed,AllocCPUS,ReqMem,MaxRSS; exit 1 ;;
    esac
    sacct -j "$job_id" --format=JobID,JobName,User,Account%40,State,ExitCode,Elapsed,AllocCPUS,ReqMem,MaxRSS
    )

    Look forAfter job-completed, read the main row: your user, normal/es_fuge or es_fuge, COMPLETED, 0:0, one CPU and 1G requested memory. Account%40 gives the account column room; normal/es+ is truncated, not an account value. MaxRSS may be on the .batch step.

    If this differsIf the state is FAILED, TIMEOUT, or OUT_OF_MEMORY, inspect logs before changing resources.

    Explanation and help
    What this means
    Use Account%40 to read the full account column, then inspect seff for the same ID. Read the small field guide above; keep actual account/user/job details private.
  8. 08

    Inspect seff

    Use Euler after you connect from your computer

    Read the requested-versus-used CPU and memory summary for the same job.

    RunThis text window after SSH connects to Euler
    (
    job_id="$(cat "$HOME/passport-euler/first-job.id")"
    case "$job_id" in ''|*[^0-9]*) printf 'STOP: stored job ID is invalid.\n' >&2; exit 1;; esac
    seff "$job_id"
    )

    Look forseff names the recorded job and reports CPU and memory use.

    If this differsUse sacct and logs if seff is not yet available; do not invent utilization values.

    Explanation and help
    What this means
    Verify the program output.
  9. 09

    Verify the environment and output markers

    Use Euler after you connect from your computer

    Read only the two expected lines from the output file for the stored job ID. They prove that the batch script used the training environment and completed its calculation.

    RunThis text window after SSH connects to Euler
    (
    job_id="$(cat "$HOME/passport-euler/first-job.id")"
    case "$job_id" in ''|*[^0-9]*) printf 'STOP: stored job ID is invalid.\n' >&2; exit 1;; esac
    output="$HOME/passport-euler/logs/passport-cpu_$job_id.out"
    grep -Fx "python_environment=passport-python" "$output"
    grep -Fx "5 squared is 25" "$output"
    )

    Look forThe command prints exactly python_environment=passport-python and 5 squared is 25.

    If this differsInspect both output and error logs for this job before changing or rerunning anything.

    Explanation and help
    What this means
    Enter the observed values in the local confirmation fields.
  10. 10

    Check and submit the mission

    On your computer

    Return to the local Passport and enter the facts you personally observed for this one job. Job ID is used locally and is excluded from public evidence. Do not enter a username, path or log. Check my work compares the entered facts; the automatic check does not connect to Euler to repeat your observations. Then submit once.

    Look forThe Passport accepts the job ID, account, owner check, queue check, final state, resources, Python environment check, seff check, and output marker.

    Explanation and help
    What this means
    Continue to accounting and right-sizing.
    Safe recovery
    Re-read the same job with sacct, seff, and its logs; do not submit another job.

Practise

One practice question. It does not affect your progress.

01The creation command printed existing-script-ok and the script. You have not used the submission step. Why might squeue be empty?
See an explanation

Creating or printing a script is a file operation. Inspect it, then use the guarded submission step once if no ID is stored. Its returned ID lets you follow the actual job; neither the marker nor an empty queue proves execution.

Finish the lesson

Questions to submit

Answer these 2 questions, then confirm the work you checked.

To pass: 100% and every safety question. Completion appears after the automatic GitHub check passes.

01Where does the actual computation run?Safety-critical
02The job is absent from squeue. What next?
Confirm the result you personally observed

These values are processed only by the local launcher. Private paths are not written to the public submission.

Before submitting
Open my real passport first

You can check sample answers here. Open your local Passport to check your practice files and submit the lesson.

Preview onlyYou can try the questions here. This page does not store or submit your answers.
Need help?Open recovery steps and AI-review guidance

If Blocked#

For an invalid account, stop and check my_share_info. For a pending job, inspect myjobs -j "$job_id" instead of submitting duplicates. Read the first meaningful error before changing resources. Use the first Euler job lab for recovery.

Useful references:

Understand Before Accepting AI Output#

Personally read the script, record the real job ID, know how to cancel it, and inspect output and accounting. An agent must not submit or enlarge the job.