Welcome Guest, Not a member yet? Register   Sign In
Cron job
#1

(This post was last modified: 06-15-2020, 06:45 AM by Didytz.)

Hi,
Can I run codeigniter Controller as CronJob and if I can is there any specific code that I need to include in it?

What I want to do is to run one file which will collect and save some data from other sources or in other words I need to cache content every 15 minutes but also would like to be able to manually run same controller if needed.

When I run my controller in "regular" way it works, but when I tell cron job to run script every 15 minutes with this command, it is not working: 
Code:
php /home/admin/web/xxxxxx.xxx/public_html/app/Controllers/Cache/Cache.php

Rest of cron job are fine as I add it directly via Vesta CP so it is not problem with scheduling, but with executing files directly this way. I guess that i need something from CLI library but what and how?
Reply
#2

(06-15-2020, 06:43 AM)Didytz Wrote: Hi,
Can I run codeigniter Controller as CronJob and if I can is there any specific code that I need to include in it?

What I want to do is to run one file which will collect and save some data from other sources or in other words I need to cache content every 15 minutes but also would like to be able to manually run same controller if needed.

When I run my controller in "regular" way it works, but when I tell cron job to run script every 15 minutes with this command, it is not working: 
Code:
php /home/admin/web/xxxxxx.xxx/public_html/app/Controllers/Cache/Cache.php

Rest of cron job are fine as I add it directly via Vesta CP so it is not problem with scheduling, but with executing files directly this way. I guess that i need something from CLI library but what and how?

Try
PHP Code:
php /home/admin/web/xxxxxx.xxx/public_html/index.php Cache/cache index 

Having the controller in a subfolder may mess this up. You might need to define a route to avoid having to put the path in the argument.
Reply
#3

(This post was last modified: 06-15-2020, 03:01 PM by Didytz.)

(06-15-2020, 10:53 AM)dave friend Wrote:
(06-15-2020, 06:43 AM)Didytz Wrote: Hi,
Can I run codeigniter Controller as CronJob and if I can is there any specific code that I need to include in it?

What I want to do is to run one file which will collect and save some data from other sources or in other words I need to cache content every 15 minutes but also would like to be able to manually run same controller if needed.

When I run my controller in "regular" way it works, but when I tell cron job to run script every 15 minutes with this command, it is not working: 
Code:
php /home/admin/web/xxxxxx.xxx/public_html/app/Controllers/Cache/Cache.php

Rest of cron job are fine as I add it directly via Vesta CP so it is not problem with scheduling, but with executing files directly this way. I guess that i need something from CLI library but what and how?

Try
PHP Code:
php /home/admin/web/xxxxxx.xxx/public_html/index.php Cache/cache index 

Having the controller in a subfolder may mess this up. You might need to define a route to avoid having to put the path in the argument.

Hmmm it seems that it is not working. What do you mean it could mess this up because of subfolder.
I can move files to Controller folder if you thing that it will fix this? Can you send me command how would it look like.

EDIT:
Sorry it is working after all, I just misspelled filename and also edited your suggestion, as my public folder is public_htm/public and you didn't include public... but this is correct way to do it.

Thank you
Reply




Theme © iAndrew 2016 - Forum software by © MyBB