Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass multiple parameters to cron job with curl?

Tags:

curl

cron

I'm running two cron jobs:

This one executes without a problem:

curl -sS http://example.com/cronjob.php?days=1

But this doesn't run at all:

curl -sS http://example.com/cronjob.php?days=1&month=1

Is this because of the ampersand (&)? If yes, how to pass multiple parameters?

Using argv is not an option.

like image 538
Yeti Avatar asked Jun 05 '10 20:06

Yeti


People also ask

How do you pass multiple parameters in curl?

Windows user running curl binaries should use double-quotes instead of single quotes to get multiple query parameters command working.


3 Answers

As an alternative way, you can use \ before & which is a special character for shell. Generally, & is one of special characters that are meaningful for shell.

So, using a backslash [beside Quoting solution] can be a good solution to this problem. more

In your example you can simply apply this command:

curl -sS http://example.com/cronjob.php?days=1\&month=1
like image 37
MMKarami Avatar answered Oct 24 '22 11:10

MMKarami


You'll notice that this doesn't exactly work in your shell, either.

What you need to do is put single quotes around the URL, like so:

curl -sS 'http://example.com/cronjob.php?days=1&month=1'
like image 172
SamB Avatar answered Oct 24 '22 11:10

SamB


Try a POST Request

curl -d "days=1&month=1" www.example.com/cronjob.php
like image 4
streetparade Avatar answered Oct 24 '22 09:10

streetparade