Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running Stata in batch mode

    Dear Statalist,

    I am using Stata through an online server and because of new setups the server logs me out after few hours. They explained me that in order to avoid losing everything I should run Stata (16 SE) in batch mode. I was looking at this guide https://www.stata.com/support/faqs/unix/batch-mode/ which suggests to use either this command

    stata -b do filename &

    or


    nohup stata -b do filename & However, when I try to digit any of the two commands in the Stata command window and I replace "do" with the do-file pathway I get an error message that says that stata or nohup are not recognised commands. Could you plase advise? I know I should provide more detailed examples but I am a bit lost here and not sure how to proceed. Thanks

  • #2
    Those commands are not Stata commands, they are Unix commands to be submitted at the Unix command prompt.

    Comment


    • #3
      Hello Raffaele,

      Have you tried creating a do file that contain all of your do files that you want to run. For example create a dofile and call it run. in this do file do the following steps

      Code:
      clear all
      set more off 
      
      
      local project_folder "Path"
      local dta_folder "Path/dta"
      local code_folder "Path/code"
      
      
      cd `dta_folder'
      do `code_folder'Name.do
      Then when you want to run the do file in the server go to your path and just type
      stata -b do run.do

      Comment


      • #4
        Thanks!

        In the Unix command prompt I typed the following code but it doesn't seem to be working.

        nohup stata -b do "/home/Documents/Do-files/Batch.do" &

        The do-file should start rewriting a log file but nothing happens (I open the dataset directly from my do-file). The Unix command prompt doesn't give me error so I assume it is a problem with something else

        Comment


        • #5
          Could it be that the Stata directory is not in your system path? What happens if you run this from your terminal:

          Code:
          nohup /full/path/to/stata -b do "/home/Documents/Do-files/Batch.do"

          Comment


          • #6
            Originally posted by Leonardo Guizzetti View Post
            Could it be that the Stata directory is not in your system path? What happens if you run this from your terminal:

            Code:
            nohup /full/path/to/stata -b do "/home/Documents/Do-files/Batch.do"
            Hi, I am not sure how to check the full path of Stata in linux. But the database manager made me type this before the command

            ssh -XY ganymede
            module load stata/16.1

            Comment

            Working...
            X