0

I'm trying to run a cron job from my hosting with cpanel, without success so far .. I followed the example of several post to do this, however these work with older versions of the framework.

I'm currently using version 3.1.4 and do not know if it has something to do, this is the command that I have so far and that does not run my cron:

/usr/local/bin/php /home/myusrname/public_html/index.php mycontroller mymethod
Vickel
  • 7,879
  • 6
  • 35
  • 56
FeRcHo
  • 1,119
  • 5
  • 14
  • 27
  • https://stackoverflow.com/questions/19199250/cronjob-in-codeigniter-using-cpanel –  Feb 23 '18 at 20:56
  • they do not work for me – FeRcHo Feb 23 '18 at 21:00
  • please check my answer here, it might help: https://stackoverflow.com/a/36190095/2275490 – Vickel Feb 23 '18 at 23:57
  • If that's a cron, wouldn't it make sense to make it a [console command](https://laravel.com/docs/5.6/artisan)? – Jared Farrish Feb 24 '18 at 00:06
  • 1
    There are a lot of reasons why your cron may not run. Are you sure that your php is at /usr/local/bin/php ?? Does the code you are trying to run use sessions or server variables ?? Have you tried to run the command via ssh terminal ?? There is no answer to this question unless you can provide more information. – Brian Gottier Feb 24 '18 at 02:21
  • You're right, I'm going to review, I'm going to review the points you mentioned and I'll expose my mistakes again – FeRcHo Feb 24 '18 at 16:16
  • @BrianGottier I just verified and if I have php in that route, it's more cpanel gives me an example to execute the command of a cron, it's something like this: /usr/local/bin/php /home/myuser/public_html/path/to/cron/script, on the other hand I do not know how to execute the command from the ssh terminal, and what I try to do execute with my script is a simple update to a table in my DB. – FeRcHo Feb 24 '18 at 18:30
  • You need to try to connect to the server via SSH. Ask your host if you can do this. Once they show you how to do it (via terminal or Putty) log in and try your command. You will then most likely see some errors. To be fair, if you're going to work with websites, you need to get used to being in the terminal and using SSH. So now is your learning experience. – Brian Gottier Feb 24 '18 at 18:40
  • @BrianGottier After some time I can change the provider, and I already have access to my small server through ssh, can you help me with this same problem please – FeRcHo Jul 31 '18 at 18:32
  • I can, but you'll need to provide real details such as error logs, the code you are trying to run, etc. – Brian Gottier Jul 31 '18 at 19:03
  • at the moment I do not have specific errors, what I am doing now is to test the code that I published previously in console, since now I have an ssh connection. I'm running this on the console: php /home/myusrname/public_html/index.php mycontroller mymethod but nothing happens, and the console does not throw any errors, when I run the previous code but with a normal php script (no codeigniter) Does this work, what other tests can I perform? – FeRcHo Jul 31 '18 at 19:26

0 Answers0