title: How can I trigger a delayed system shutdown from in a shell script?
body: <p>On my private network I have a backup server, which runs a bacula backup every night. To save energy I use a cron job to wake the server, but I haven't found out, how to properly shut it down after the backup is done. 
  By the means of the bacula-director configuration I can call a script during the processing of the last backup job (i.e. the backup of the file catalog). I tried to use this script: </p>
  
  <pre><code>#!/bin/bash
  # shutdown server in 10 minutes
  #
  # ps, 17.11.2013
  bash -c "nohup /sbin/shutdown -h 10" &amp;
  exit 0
  </code></pre>
  
  <p>The script shuts down the server - but apparently it returns just during the shutdown, 
  and as a consequence that last backup job hangs just until the shutdown. How can I make the script to file the shutdown and return immediately?</p>
  
  <p>Update: After an extensive search I came up with a (albeit pretty ugly) solution: 
  The script run by bacula looks like this: </p>
  
  <pre><code>#!/bin/bash
  at -f /root/scripts/shutdown_now.sh now + 10 minutes
  </code></pre>
  
  <p>And the second script (shutdown_now.sh) looks like this: </p>
  
  <pre><code>#!/bin/bash
  shutdown -h now
  </code></pre>
  
  <p>Actually I found no obvious method to add the required parameters of shutdown in the syntax of the 'at' command. Maybe someone can give me some advice here. </p>