0

So I have php script, and want to run in with cron tab (unix)

php script url:

https://www.domain.com/admin/index.php?route=do&key=54asd55asd

How can add it to crontab?

I tried

* * * * * lynx -dump https://www.domain.com/admin/index.php?route=do&key=54asd55asd
* * * * * wget https://www.domain.com/admin/index.php?route=do&key=54asd55asd

but no luck.

Any ideas?

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Aleksandr
  • 91
  • 10
  • The problem lies in the `&` that don't go through. What if you quote the URL --> `wget "https://..."`? – fedorqui Apr 21 '16 at 14:00

2 Answers2

0

Instead of trying to use a cli browser, use curl instead, with which you will be able to send POST parameters as well if you need to.

slax0r
  • 688
  • 4
  • 8
0

The are a few options here, depending on GET/POST request:

GET Request:

* * * * * * /usr/bin/GET http://www.example.com?foo=1 >/dev/null 2>&1 * * * * * * /usr/bin/wget -O - http://www.example.com/file.php?foo=1 >/dev/null 2>&1

Or POST:

* * * * * * /usr/bin/curl --data "foo=1" http://www.example.com/file.php >/dev/null 2>&1

I would look into the cURL Manual

Could also write a php file to curl the site for you, then add that to your crontab. For instance: How would I use a cron job to send an HTML GET request. Then handling of errors and whatnot could be dealt with locally.

Community
  • 1
  • 1
Hexchaimen
  • 341
  • 2
  • 9