Set nice value and detach from cron
[backups/.git] / scripts / burn-imgs.sh
index 2be9e0a664eb26da16a150ff84639c7ce656e5f4..b4d71bf807219ff3189e41894780f1a971d6a9d7 100755 (executable)
@@ -2,6 +2,7 @@
 
 export PATH=$(dirname $0):/bin:/usr/bin:/sbin
 
+cronstopstart="/etc/init.d/cron"
 . config.sh
 
 # If the noburn file is there then don't burn.
@@ -31,6 +32,10 @@ touch $noburnfile
 [ -z "$img" ] && exit 1
 [ -s "$img" ] || exit 1
 
+# To avoid buffer underruns I'm going to stop cron and renice myself
+$cronstopstart stop
+renice -10 $$
+
 # Burn the image to a disk.
 cdrecord-wrapper.sh -dao dev=$sdev $img > $logfile 2>&1
 
@@ -39,6 +44,10 @@ if [ "0" != "$?" ]; then
   exit 1
 fi
 
+# We don't need to be high-priority anymore.
+renice 0 $$
+$cronstopstart start
+
 # Now verify the disk by running md5sum on the entire contents of the disk
 md5sum=$(tempfile)
 echo Md5sum: $md5sum