-1

I have written a crontab to call a function with following syntax to run every 5 minutes,

*/5 * * * * curl http://localhost/domain/path/front_orders/recursive_pay/F0C473D9BD583

in the function, I have redirected to google with redirect('http://www.google.com');for test but it does not seem to work.Any suggestions..

Umes Bastola
  • 527
  • 2
  • 6
  • 18
  • 2
    What do you want? Cron job won't redirect. How can a Terminal / shell redirect to a webpage? – Raptor Oct 14 '14 at 06:11
  • 1
    The `php` command runs *local PHP files*, eg. `php cron.php foo`. The `curl/wget` command runs *remote PHP files (files though the webserver)*, eg. `curl http://www.domain.com?function=foo`. – h2ooooooo Oct 14 '14 at 06:13
  • Related to http://stackoverflow.com/questions/5766772/using-wget-to-run-a-cronjob-php – Shadow Radiance Oct 14 '14 at 06:19
  • Here is a complete explanation http://www.thegeekstuff.com/2011/07/php-cron-job/ – Jyothish Oct 14 '14 at 06:22

3 Answers3

0

instead of redirect('http://www.google.com'); trying using this:

header('Location: http://www.google.com');
Siniseus
  • 121
  • 6
0

Use curl or wget if you want to just "ping" a url.

*/5 * * * * /usr/bin/wget -O /dev/null http://localhost/domain/path/front_orders/recursive_pay/F0C473D9BD583

You can also use one of

/usr/bin/wget --spider http://localhost/... (if doing a HEAD call will do)
/usr/bin/curl http://localhost/... > dev/null 2>&1

If you use

/usr/bin/wget -q http://localhost/... 

I think you will end up putting a copy of the result in whatever the 'current' directory is (differs based on which user's cron is running).

Shadow Radiance
  • 1,349
  • 13
  • 20
0

If your php script can be invoked using an URL, you can lynx, or curl, or wget to setup your crontab.

*/5 * * * * lynx  http://localhost/domain/path/front_orders/recursive_pay/F0C473D9BD583.php

or

*/5 * * * * /usr/bin/curl  http://localhost/domain/path/front_orders/recursive_pay/F0C473D9BD583

or

*/5 * * * * /usr/bin/wget -q  http://localhost/domain/path/front_orders/recursive_pay/F0C473D9BD583
Jyothish
  • 154
  • 2
  • 11