Skip to content

Instantly share code, notes, and snippets.

@ctrlcctrlv
Created April 18, 2014 08:57
Show Gist options
  • Select an option

  • Save ctrlcctrlv/11032666 to your computer and use it in GitHub Desktop.

Select an option

Save ctrlcctrlv/11032666 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Save $1 because `set` will overwrite it
QUEUE_TO_DELETE=$1;
# $1 is our job ID, $7 is our queue name
ATQ=`atq|awk '{print $1, $7}'`;
while read line
do
set $line;
# $1 is still our job ID, $2 is now our queue name
if [ "$2" == "$QUEUE_TO_DELETE" ] || [ "$QUEUE_TO_DELETE" == '--all' ]
then
atrm $1;
if [ $? -ne 0 ]
then
echo "Failed to delete job $1" 1>&2;
fi
echo "Deleted job $1" 1>&2;
fi
done <<< "$ATQ"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment