• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use cronjob in codeigniter?

#1
Hello all. I am interested in using cronjob in codeigniter framework. I have controller named welcome   and method inside it named auto  
how can i use cronjob and call this url     http://www.mywebsite.com/welcome/auto     using cronjob  ?
Reply

#2
That is probably a question for your system administrator rather then a CodeIgniter question since it depends on your OS (Linux, Windows, Solaris etc.) and also your distribution/version. There are simply a lot of different ways depending on your tools.

Also, you fail to mention what your controller/method is supposed to do. Is it enough to "download" it, or do you want to send parameters or process the result in any way?

On my Linux Ubuntu 14.10 I could for example execute
# crontab -e

This will edit the list of cron commands tied to my user (editor depends on what is installed in your system). I would and then add the following line
0 * * * * wget http://www.mywebsite.com/welcome/auto

This will "visit" your website once every hour and download the output, however the output would simply be discarded.

Kind regards,

Daniel Sahlberg
Reply

#3
For that you can use CI over the built in cli

http://www.codeigniter.com/userguide3/general/cli.html

In your cronjob file you can set the roule and call your job like

PHP Code:
* * * * php /path_to_your_ci_root/index.php welcome auto 

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.