Will this cronjob work?

im trying to configure cronjob to run a php file. I just want to know if I'm doing it right or not.

let's say php is at http://mysite.com/myscript/cronjob.php and I want it to run every 3 hours.

I am very new to cronjobs, so I apologize if it seems to me that I have no idea what I'm doing.

Minute  Hour    Day     Month   Weekday     Command

*   */3     *   *   *   http://mysite.com/myscript/cronjob.php

I want this to run a PHP script every 3 hours. will this work or should i use another command?

+5
source share
3 answers

No, that will not work. The url is not executable, it is just a url.

You can put wget http://mysite.com/myscript/cronjob.phpfor your team, but is that really what you want?

( script ) - PHP:

php /var/www/myscript/cronjob.php

+5

,

* */3 * * * wget -q -o /dev/null http://mysite.com/myscript/cronjob.php

curl

* */3 * * * curl -s -o /dev/null http://mysite.com/myscript/cronjob.php

-s/-q , -o /dev/null

+4

In addition to what others have said about the impossibility of providing a URL for the request:

I found some links on the Internet which warn

and. ) Repeat the pattern as / 2 every 2 minutes or / 10 for every 10 minutes, not supported by all operating systems. If you try to use it and crontab complains, it is probably not supported.

However, if it is assumed that duplicate patterns are supported, it should work.

So, a more portable way:

*   0,3,9,12,15,18,21     *   *   *   php /var/www/myscript/cronjob.php
0
source

All Articles