Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: shell without waiting in unix batch mode?


From   M Hollis <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: shell without waiting in unix batch mode?
Date   Thu, 21 Jun 2012 21:06:22 -0700 (PDT)

That does the trick! Thanks. It executed A and B in parallel. It still waits for the shell to finish, in this example it waited for the longer job (B) to complete before proceeding, but in most cases that's actually preferable since it means that I don't have to create some trick so that Stata knows when the last one is done. 

This will definitely be useful, thanks.

Matissa


----- Original Message -----
From: Richard Herron <[email protected]>
To: [email protected]
Cc: 
Sent: Thursday, June 21, 2012 5:43 PM
Subject: Re: st: shell without waiting in unix batch mode?

You can string together shell commands with a semicolon. But here,
even with the ampersand, it doesn't return control to shell. So you
should wrap each command with parentheses, which will send the process
to the background and return control to shell (I don't have enough
*nix knowledge to know _exactly_ why this is).

Please try as your new ExampleMaster.do.

* begin code
set rmsg on
shell (stata -b do "ExampleB" &); (stata -b do "ExampleA" &)
* end code

I think the normal usage for the parentheses trick is in a shell
for-loop to spawn a lot of processes, but it should work here, too.
HTH.

Richard Herron


On Thu, Jun 21, 2012 at 5:07 PM, Brendan Halpin <[email protected]>
wrote:
>
> On Thu, Jun 21 2012, M Hollis wrote:
>
> > Hi,
> >
> > I'm running some do-files on a unix server in batch mode. The server has
> > multiple processors and so there are instances where I'd like to be able
> > to have my do-file complete some initial data preparation tasks and then
> > submit multiple jobs simultaneously (in parallel). In this particular
> > case I'm submitting a job to R, using Amelia for MI, and the imputation
> > takes quite a while to run. I'd like to run the imputation separately
> > for men and women and it would be ideal to run the analysis in parallel
> > by calling R twice, but I can't figure out how to use the shell command
> > without having Stata wait for the process to complete before continuing.
>
> I asked a similar question about four weeks ago, and came up blank. My
> example had to do with time-consuming conversions of graph formats using
> unix command-line tools, but the benefit of launching asynchronous
> processes is clear.
>
> I'm beginning to think there is no direct way to do this with Stata, but
> I haven't given up hope of a workaround (perhaps submit the job to the
> "at" queue with a time of "now"?).
>
>
> Brendan
>
> --
> Brendan Halpin,   Department of Sociology,   University of Limerick,
> Ireland
> Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-009 x
> 3147
> mailto:[email protected]    ULSociology on Facebook:
> http://on.fb.me/fjIK9t
> http://teaching.sociology.ul.ie/bhalpin/wordpress
> twitter:@ULSociology
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index