0

So i have this php function path in codeigniter which I am trying to run through cron job in ubuntu. But whatever I have tried it is not working. The command I have tried so far

* * * * * /usr/bin/php http://localhost/QAPIv2/updateTestData

But it is not executing. I am using codeigniter

Sarkar
  • 61
  • 2
  • 12
  • 1
    Does this answer your question? [CRON command to run URL address every 5 minutes](https://stackoverflow.com/questions/11375260/cron-command-to-run-url-address-every-5-minutes) – ADyson Jun 18 '22 at 11:35

3 Answers3

1

To elaborate on Rohan's answer, you run the functions like php index.php controller function. So, for example, to run your script every Tuesday at 8:31AM, your crontab entry should look like :

31 08 * * 2 cd /path/to/codeigniter; /usr/bin/php index.php QAPIv2 updateTestData;
Marshall C
  • 359
  • 3
  • 8
0

Try this:

*/1 * * * * /usr/bin/php /var/www/html/YOUR PROJECT FOLDER NAME/index.php YOUR FUNCTION NAME > /dev/null 2>&1

First number is time for cron.In function name you should give the controller function name which you want to load in cron.

  • `Try this`...because? You should always explain your answer and show why it would help or fix the issue, otherwise people are just guessing or hoping, and maybe not even understanding the significant parts of the code. See also [answer]. Thanks. – ADyson Jun 21 '22 at 10:58
  • ok noted @ADyson – arunfrancis Jun 21 '22 at 11:01
  • Rather than simply noting it, how about editing your answer? – ADyson Jun 21 '22 at 11:11
  • You just change the color of var.This is not editing. – arunfrancis Jun 21 '22 at 12:02
  • I changed the formatting to make the code viewable as per Stackoverflow standards - see [How do I format my posts?](https://stackoverflow.com/help/formatting) for future reference on how you can do that yourself. But **you** need to edit it to add the requested explanation of what you have shown, I cannot do that for you because I don't know what your exact reasoning is for suggesting this piece of code or why you expect it to solve the OP's issue. – ADyson Jun 21 '22 at 12:15
  • If you don't edit it, then the downvote will stay, you may attract more downvotes, and/or the answer may eventually be deleted as being not useful. Or if you don't wish to amend it, your 3rd option is to delete it yourself. – ADyson Jun 21 '22 at 13:11
-1

Please call the function from the command line.

$ cd /path/to/project;
$ php index.php controller function

Please change the controller and function according to your code.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • Perhaps, but this not clear from your answer if you ask. Also adding any link to docs about that would additionally help your answer look more trustworthy. – Marcin Orlowski Jun 18 '22 at 13:37