-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcosmosim-deletejobs.sh
47 lines (39 loc) · 1.39 KB
/
cosmosim-deletejobs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# Remove own jobs from CosmoSim, based on jobids in given file.
# If you don't have the jobids, get a list of all jobs by running
# http --auth $username:$password --print b GET http://www.cosmosim.org/uws/query
# Also consider using the uws-client (https://github.com/adrpar/uws-client) for this.
# The astroquery.cosmosim-package (https://github.com/agroener/astroquery) also has nice
# features for deleting.
#
# Note: if running jobs get a 'delete' signal, they will only be stopped.
#
# Needs httpie:
# https://github.com/jkbr/httpie
# Documentation on CosmoSim's UWS interface:
# https://www.cosmosim.org/cms/documentation/data-access/access-via-uws/
#
# Author: Kristin Riebe, AIP, November 2014
if [ $# -lt 1 ]
then
echo "Please provide a filename with jobids as command line argument, e.g.:"
echo " bash cosmosim-deletejobs.sh jobids.txt"
exit
fi
username='xxxxxx'
password='xxxxxx'
url='https://www.cosmosim.org/uws/query'
idfile=$1
# read file with jobids
declare -a jobidlist
jobidlist=(`less $idfile`)
numid=${#jobidlist[*]}
# If all jobs have completed, you can retrieve the results:
echo "Trying to delete the jobs. There is no error handling included here, so it may break."
# get result-urls and download to files
for (( i=0; i<$numid; i++ ))
do
cmd="http --auth ${username}:${password} --follow DELETE ${url}/${jobidlist[$i]}"
results=`$cmd`
done