-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.sh
More file actions
executable file
·59 lines (55 loc) · 1.32 KB
/
main.sh
File metadata and controls
executable file
·59 lines (55 loc) · 1.32 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# Default values
node="node01"
queue="short"
ppn="24"
name="ReservePBSNode"
# Handle SIGINT (Ctrl+C) to clean up the PBS script
trap "echo 'Cleaning up...'; rm -f reserve_$name.pbs; exit 0" INT
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
-n|--node) node="$2"; shift ;;
-q|--queue) queue="$2"; shift ;;
-p|--ppn) ppn="$2"; shift ;;
-N|--name) name="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
# Write a PBS script to run a job on the specified node
cat << EOF > reserve_$name.pbs
#!/usr/bin/env bash
#PBS -N $name
#PBS -l select=1:ncpus=$ppn:host=$node
#PBS -l walltime=00:30:00
#PBS -q $queue
#PBS -j oe
# Change to the directory from which the job was submitted
cd \$PBS_O_WORKDIR
# Run a simple command to keep the job active
sleep 30m
EOF
chmod +x reserve_$name.pbs
while true; do
echo "Current cluster nodes status:"
pbsnodes -aSj
echo ""
# Submit the job to the cluster
job=$(qsub reserve_$name.pbs)
echo "Submitted job $job"
echo ""
echo "Current job status for user $USER:"
qstat -u $USER
echo ""
echo "Tracing job $job:"
tracejob $job
echo ""
echo "Info for node $node:"
pbsnodes $node
echo ""
echo "Sleeping for 30 minutes before checking again..."
sleep 30m
echo ""
echo ""
done