I have a function that I want to execute through cron. If I simply hit the url www.example.com/TestProjects/codeigniter/controller/function
This function executes fine, if I set it on cron does not work.
I tried setting this as
public_html/TestProjects/codeigniter/controller/function
and this through such error message
public_html/TestProjects/codeigniter/controller/function: Not a directory
Can anyone help me how to set this on cron?
At first try to run that controller method in CLI mode. In console, go to your project directory an then run your script in CLI mode:
cd TestProjests/codeigniter
php index.php controller function
If this will work, insert the same line to crontab, but with absolute path:
php /path_to_your_projects/TestProjests/codeigniter/index.php controller function
This can also help you: https://ellislab.com/codeigniter/user-guide/general/cli.html
** hi dude try this **
The path public_html/TestProject/...
is almost certainly a relative path from your user directory. You can use wget
in your cron to hit the url:
* * * * * wget http://www.example.com/cronscript > /dev/null
Alter the time above to let it run as much as you like
在执行空格后使用系统路径到文件名和函数名,它应如下所示:
php /var/www/path/to/controller/classFile functionName
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.