-
-
Save leverich/bc953d925737f149ae95 to your computer and use it in GitHub Desktop.
jsub - convenient qsub wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
$usage = "jsub version 0.3 | |
Synopsis: | |
jsub is a speck of a Perl script designed to make life with Torque | |
a little bit more pleasant. It mimics the functionality of LSF's | |
bsub; that is, you can directly specify the command (and arguments) | |
that you want to submit as a batch job rather than having to write | |
a submission script. It also supports non-shell interactive jobs. | |
Usage: | |
jsub [-Q] [<qsub args> ..] -- <command> [<args> ..] | |
-Q Shortcut for -o /dev/null -e /dev/null | |
jsub automatically sets the following qsub arguments: | |
-V -d \"<CWD>\" -N <truncated name> | |
See qsub(1B) for details on qsub arguments. | |
Example: | |
# jsub -I -- hostname | |
qsub: waiting for job 379.cyclades-master.stanford.edu to start | |
qsub: job 379.cyclades-master.stanford.edu ready | |
campari.Stanford.EDU | |
qsub: job 379.cyclades-master.stanford.edu completed | |
"; | |
while (scalar @ARGV and $ARGV[0] ne "--") { | |
push @QARG, shift @ARGV; | |
} | |
shift @ARGV; # dump the -- | |
$name = join("", @ARGV); | |
$name =~ s/[\W_]//g; | |
$name = substr($name, 0, 15); | |
# map { $_ = "\"$_\"" } @ARGV; | |
chomp ($CWD = `pwd`); | |
if (grep /-Q/, @QARG) { | |
push @QARG, (qw:-j oe -o /tmp -e /tmp:); | |
@QARG = grep !/-Q/, @QARG; | |
} | |
push @QARG, "-V"; | |
push @QARG, "-d", "$CWD"; | |
push @QARG, "-N", "$name"; | |
unless (scalar @ARGV) { | |
print $usage; | |
exit 1; | |
} | |
chomp ($tempfile = `mktemp -p "$ENV{HOME}" .jsub.tmp.XXXXXXXXXX`); | |
push @QARG, "-S", "$tempfile" if grep /-I/, @QARG; | |
open TMP, ">$tempfile" or die $!; | |
print TMP "#!/bin/bash\n"; | |
print TMP join(" ", @ARGV), "\n"; | |
chmod 0755, $tempfile; | |
close TMP; | |
unshift @QARG, $tempfile unless grep /-I/, @QARG; | |
system("/usr/bin/qsub", @QARG); | |
unlink($tempfile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment