Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8132079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:15:31+00:00 2026-06-06T09:15:31+00:00

I have a script test.R that takes arguments arg1 , arg2 and outputs a

  • 0

I have a script test.R that takes arguments arg1, arg2 and outputs a arg1-arg2.csv file.

I would like to run the test.R in 6 parallel sessions (i am on a 6 core CPU) and in the background. How can I do it?

I am on linux

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:15:32+00:00Added an answer on June 6, 2026 at 9:15 am

    You did not provide a reproducible example so I am making one up. As you are on Linux, I am also swicthing to littler which was after all writtten for the very purpose of scripting with R.

    #!/usr/bin/env r
    #
    # a simple example to install one or more packages
    
    if (is.null(argv) | length(argv) != 2) {
        cat("Usage: myscript.r arg1 arg2\n")
        q()
    }
    
    filename <- sprintf("%s-%s.csv", argv[1], argv[2])
    Sys.sleep(60)   # do some real work here instead
    write.csv(matrix(rnorm(9), 3, 3), file=filename)
    

    and you can then lauch this either from the command-line as I do here, or from another (shell) script. The key is the & at the end to send it in the background:

    edd@max:/tmp/tempdir$ ../myscript.r a b &
    [1] 19575
    edd@max:/tmp/tempdir$ ../myscript.r c d &
    [2] 19590
    edd@max:/tmp/tempdir$ ../myscript.r e f &
    [3] 19607
    edd@max:/tmp/tempdir$
    

    The [$n] indicates how process how been launched in the background, the number that follows is the process id which you can use to monitor or kill. After a little while we get the results:

    edd@max:/tmp/tempdir$ 
    [1]   Done                    ../myscript.r a b
    [2]-  Done                    ../myscript.r c d
    [3]+  Done                    ../myscript.r e f
    edd@max:/tmp/tempdir$ ls -ltr
    total 12
    -rw-rw-r-- 1 edd edd 192 Jun 24 09:39 a-b.csv
    -rw-rw-r-- 1 edd edd 193 Jun 24 09:40 c-d.csv
    -rw-rw-r-- 1 edd edd 193 Jun 24 09:40 e-f.csv
    edd@max:/tmp/tempdir$ 
    

    You may want to read up on Unix shells to learn more about &m the fg and bg background s etc.

    Lastly, all this can a) also be done with Rscript though picking arguments is slightly different and b) there are CRAN packages getopt and optparse to facilitate working with command-line arguments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so i have ruby script that simply writes to a test.txt file with hello
I have a batch script that looks like this: Test.bat @echo off :: Starts
I have a python script that takes input using a pattern like this: 1**
I have bash script that takes in a couple of arguments tests then and
I have the following simple python test script that uses Suds to call a
We have a ubuntu test server that this simple script works fine on where
I have created a script to run a test script on a batch of
I'm writing a script that takes command line arguments. Using BBEdit 10.0.1 on Mac
I have the following PowerShell script that will parse some very large file for
I've written a script that saves its output to a CSV file for later

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.