System - Luk computeren NU


Source: Download script

Last Updated: 11. September 2025 by Agnete Moos (agms@sonderborg.dk)

Click to see the source code
#!/usr/bin/env bash

set_job_status() {
  STATUS=$1

  JOB_STATUS_PATH="$(dirname "$0")/status"

  echo -n "$STATUS" > "$JOB_STATUS_PATH"
}

# Set successful exit status for the job as otherwise it ends in PENDING and
# ultimately FAILED because it shuts down before it gets to the point
# where it reports back
set_job_status "DONE"

shutdown now

# If the script reaches this point the command failed, and so we re-set the status accordingly
set_job_status "FAILED"

Beskrivelse

Luk computeren ned med det samme, UDEN at varsko en eventuel bruger eller i øvrigt vente på noget som helst.

BEMÆRK: Man vil herefter skulle tænde for computeren manuelt, for at få den i gang igen. En computer, der er tilknyttet en tænd/sluk tidsplan, vil dog stadig vågne efter tidsplanen.

Dette script er blevet testet og virker på Ubuntu 22.04.