Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set non-default project name for qmake jobs

Set non-default project name for qmake jobs

This is a hack to run jobs on an SGE cluster using qmake under another project than your default project.

Most of the SGE job runners have the -P option. Unfortunately, as the manpage mentions, the option is not available for qmake:

-P project_name
       Available for qsub, qsh, qrsh, qlogin and qalter only.
       Specifies the project to which this job is assigned.

You can however change the job's project after it was submitted with qualter. The problem is that a typical qmake invocation keeps generating new jobs and they are not easily recognizable between jobs from other qmake invocations.

I run qmake with a (unique) environment variable that ends up in the job contexts (you can see it with qstat -j), example:

CHANGE_TO_XYZ=1 qmake -V -cwd -l arch=linux-x64 -inherit -- -j 120

Then I run a Bash loop that (every N seconds) changes the project for all jobs in qw state having the specified environment variable:

while true; do
  for job in $(qstat | grep qw | cut -d ' ' -f 1); do
    qstat -j $job | grep -q CHANGE_TO_XYZ && qalter -P XYZ $job
  done
  sleep 60
done

This only works if the qalter is done before the job went from qw to r so the sleep should not be too long. (But if you are desperate enough to use this, your jobs will probably be in qw for some time.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.