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 8439011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:53:12+00:00 2026-06-10T07:53:12+00:00

In crontab, I have added a php script name, running this script from CLI

  • 0

In crontab, I have added a php script name, running this script from CLI SAPI mode, so no max_execution_time problem.

I can pass several parameters using spaces.

system('/path/of/your/script.php param1 param2 > scriptlog.txt &')

But I need to pass an array as parameter is shell script and breakdown the array.

for example,

system('/path/of/your/script.php array > scriptlog.txt &')
  • 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-10T07:53:14+00:00Added an answer on June 10, 2026 at 7:53 am

    When you cast system in your app, you must implode your parameters
    Just pass arguments successively like

    system('/path/of/your/script.php param[0] param[1] > scriptlog.txt &')
    

    This would look like

    system('/path/of/your/script.php '.implode(" ",$params).' > scriptlog.txt &')
    

    If you’re having quotes, you can take a look at escapeshellarg

    system('/path/of/your/script.php '.implode(" ",array_map("escapeshellarg",$params)).' > scriptlog.txt &')
    

    Then in your script.php, catch parameters with

    $args = $argv;
    array_shift($args); //Because $args[0] is 'script.php'
    

    If you’re catching > scriptlog.txt & in your script.php, use this instead:

    $args = $argv;
    if (false !== ($pos = array_search(">",$args))) {
        $args = array_slice($args,1,$pos-1);
    } else {
        array_shift($args);
    }
    

    Note that this works only if your array is non-associative.
    You’ll need to write another function to retrieve associative params

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

Sidebar

Related Questions

I have a PHP script running via crontab on hourly basis under Linux. This
i have this crontab, * * * * * php /etc/raddb/overloaded.php but it is
I have a bash script activated by crontab and running in background. I would
I have debian linux. I've created from user crontab -e this text: 0 *
I have verified that my php script runs from the command line, but it
I have a php script I want to execute regularly using a crontab. I've
I have a shell script that I can run with root user this way:
The problem i have is that i have created newsletter template, added few subscribers
I have a script that I'm trying to run from cron. When I run
I have an entry in my crontab that looks like this: 0 3 *

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.