0

I tried to set cronjob on my server for ActiveCollab I use this

*/5 *   *   *   *   php "/home/bbb/public_html/tasks/frequently.php" RnuFA > /dev/null

but it always returns error message :

Status: 301 Moved Permanently

Location: https://mywebsite.com/

Content-type: text/html

I've tried to execute the command through SSH and it worked properly.

Can someone help me telling what configuration on my server that need to be checked for this kind of issue?

Thank you

Community
  • 1
  • 1
webchun
  • 1,204
  • 2
  • 13
  • 30
  • Do you get the same error when you run `php "/home/bbb/public_html/tasks/frequently.php" RnuFA` from the cmd_line? Please edit your question to include that info. Just noticed "Execute from ssh and it works".. Hmm.. why not have the crontab entry call ssh? But it's not clear what the remote target is. Where is `https://mywebsite.com/` specified? Good luck. – shellter Jun 25 '14 at 17:55
  • Yet it work properly with SSH. Strangely it also running fine when I use root account to run that cron. – webchun Jun 26 '14 at 00:02
  • I won't be able to go thru a test of each element in the chain, But 2nd most likely cause is elements of `PATH` or `LD_LIBRARY*` or `???` env are different between `root` and your crontab's environment. The 1st most likely is that you've created some of this code in Windows and copied to Linux. If that is the case, use `dos2unix file` to replace pesky `\r\n` line-endings with Unix friendly `\n` . Good luck! – shellter Jun 26 '14 at 03:36
  • Are you forcing SSL in any way? Are you using cpanel? (since it can affect how you have to call the cron) Have you tried to set the full path to the php? Definitely try that. Hope it helps :) – Diogo Raminhos Jun 26 '14 at 22:12
  • @Whiteagle yesw, I'm using cpanel and full path didn't work too – webchun Jun 28 '14 at 01:57
  • @Whiteagle and yes I'm forcing SSL – webchun Jun 28 '14 at 07:41
  • @dreamexploded how are you forcing the SSL? Have you used .htaccess or edited any of the activecollab files? – Diogo Raminhos Jun 28 '14 at 17:40

1 Answers1

1

Official recommendation is to use cURL to trigger scheduled tasks, not executable PHP. Currently it is just a recommendation, but upcoming releases will stop shipping /tasks folder so you will have to use cURL.

There are many environments (more than we expected) where there is one PHP that web server uses to prepare the page, and another PHP that runs via command line interface (CLI). This causes all sort of problems, so we decided to use only way way of triggering tasks - via URL.

Bottom line - use cURL. Documentation is here:

https://activecollab.com/help/books/self-hosted-edition/scheduled-tasks-setup.html

Here are sample commands:

*/3       *      *       *       *       /usr/bin/curl -s -L "http://url/of/frequently?code=XyZty" > /dev/null
0         *      *       *       *       /usr/bin/curl -s -L "http://url/of/hourly?code=XyZty" > /dev/null
0        12      *       *       *       /usr/bin/curl -s -L "http://url/of/daily?code=XyZty" > /dev/null
0         7      *       *       *       /usr/bin/curl -s -L "http://url/of/paper?code=XyZty" > /dev/null

but make sure to check Administration > Scheduled Tasks page of your activeCollab for exact URLs that you need to trigger.

Ilija
  • 4,105
  • 4
  • 32
  • 46