Setting up a cron job using codeigniter

I have a function that I want to execute via cron. If I just remove the urlwww.example.com/TestProjects/codeigniter/controller/function

This function works fine, if I set it to cron doesn't work.

I tried to set this like

public_html/TestProjects/codeigniter/controller/function

      

and this is through this error message

public_html/TestProjects/codeigniter/controller/function: Not a directory

      

Can anyone help me set this on cron?

+3


source to share


4 answers


**   hi dude try this **

      



curl http://nztdemo.com/TestProjects/ERP/cron/index

+2


source


First try running this controller method in CLI mode. In the console, navigate to your project directory and then run your script in CLI mode:

    cd TestProjests/codeigniter
    php index.php controller function

      

If that works, paste the same line into the crontab, but with an absolute path:



    php /path_to_your_projects/TestProjests/codeigniter/index.php controller function

      

This might help you too: https://ellislab.com/codeigniter/user-guide/general/cli.html

+2


source


The path is public_html/TestProject/...

almost certainly a relative path from your user directory. You can use wget

in your cron to push to url:

* * * * * wget http://www.example.com/cronscript > /dev/null

      

Change the times above to make it work the way you like

+1


source


Use system path for filename and function name after executing the space, it should look like this:

php /var/www/path/to/controller/classFile functionName

      

-1


source







All Articles