help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Fwd: Proper use of nohup within here-document?


From: Assaf Gordon
Subject: Re: [Help-bash] Fwd: Proper use of nohup within here-document?
Date: Thu, 22 Mar 2018 15:42:32 -0600
User-agent: Mutt/1.5.24 (2015-08-30)

Hello,

slightly off-topic, but perhaps it'll help:

> On Thu, Mar 22, 2018 at 12:04:20PM -0700, Mun wrote:
>> My here-document looks something like this:
>>
>> ========================================
>> cat >myScript <<@EOF
>> #! /bin/bash
>>
>> date > showMe.txt
>> nohup gxmessage -timeout 0 -file showMe.txt > /dev/null 2>&1 &
>>
>> @EOF
>>
>> chmod 777 myScript
>> qsub -b yes -sync n ./myScript
>> ========================================

There seem to be several strange things here:

1. qsub submits a job to the grid engine (and I assume it is SGE = Sun Grid 
Engine
based on the paramaters). The job (your script) will run on a different machine
(one of the SGE nodes).


2. Using "-b yes" means that you are executing a binary file (e.g. compiled C 
program)
as opposed to a shell script. But you *are* queueing a shell script.
So why use "-b yes" ?


3. If "gxmessage" is GTK-xmessage [1] then it is a graphical program
that needs X11 display. But you will certainly not have X11 connection
on the SGE node that actually runs the job (i.e. the "$DISPLAY" variable
will be empty, and gxmessage will fail like so:

  $ DISPLAY= gxmessage
  Unable to init server: Could not connect: Connection refused
  gxmessage: unable to initialize GTK

So it is not entirely clear what you are aiming to do here.

[1] http://manpages.ubuntu.com/manpages/trusty/man1/gxmessage.1.html


4. A typical SGE job is scheduled (queued) to be run later (when an SGE
node is available, which might be immediately). The job will be active
until the main script is done.
So why execute a program in the background with nohup?
Do you want to try and leave a background program running on the SGE node
and keep consuming resources after the job is officially over?


5. It is recommended not to redirect STDOUT and STDERR to /dev/null with SGE.
Typically, 'qsub' will print a job ID (e.g. "Job 12345 submitted"),
and once the job is completed (on a different node), STDOUT and STDERR of the 
job
will be saved in your $HOME directory as "myScript.o12345" and 
"myScript.e12345".
(o=out, e=err). This will quickly show you what errors are encounterd
(e.g. "gxmessage" will complain about missing $DISPLAY).


HTH,
 - assaf



reply via email to

[Prev in Thread] Current Thread [Next in Thread]