[SOLVED] Cronjob on Sharedhosting

Hello,

I’m current having an issue with my instance of Kanboard. I’m using a shared-hosting, and Kanboard was installed using the Softaculous installation mode.

One issue that I noticed is that the Softaculous script creates a cronjob like mentioned in the documentation, but this is not working. I’ve tried to change the code of it (by adding php before cli otherwise I do get an error), but it still doesn’t work.

The weirdest part, is that if I open the cPanel’s terminal and I do paste the code of the cronjob, the automations set on the projects do work as expected.

The current code is: (I’ve replaced the user and domain here, for privacy reasons)

cd /home/<my_user>/<my.domain.com> && php cli cronjob >/dev/null 2>&1

I’ve reached out to the hosting support, and they told me that from their side the cronjob is working as expected.

Does anyone have any idea what might be the issue here?

Best regards!


Edit: This comment helped me to solve the issue. In my case, using /usr/local/bin/php /home/<my_user>/<my.domain>/cli cronjob >/dev/null 2>&1 worked.

I added an output to a log file and this seems to be the message:

Content-type: text/html; charset=UTF-8

This script run only from the command line

First off, this contains an error. The correct redirection is 2>&1 > /dev/null.
Hint: Never add the redirection until you’re sure the command really works.

Please explain in detail how you invoke the cronjob command.

Okay. The >/dev/null 2>&1 was already created by the Softaculous installer, hence why I only changed the first part of the command.

They even specify that in their documentation.

The cPanel has an option to create Cron jobs, it’s the only thing we can use:

If I need to run it, I just set a short time, to test.

Maybe I was wrong, this might work either,

Now that you have marked this topic a solved, could you summarize your solution here? It might be very helpful for other cPanel users.

Solution for cPanel users

The Softaculous installer, creates a cron job automatically for Kanboard. If, for some reason, it doesn’t work properly for you, follow these steps:

  1. In cPanel go to the Cron Jobs option.
  2. The Current Cron Jobs section might have more than one job (depending on your usage). The Kanboard one should be the one which has the command like this: cd /home/<YOUR_USER>/<YOUR_DOMAIN.com> && php cli cronjob >/dev/null 2>&1 (YOUR_USER and YOUR_DOMAIN are just placeholders. You should have a different value).
  3. Edit that one and just change that command into /usr/local/bin/php /home/<YOUR_USER>/<YOUR_DOMAIN.com>/cli cronjob >/dev/null 2>&1

For custom PHP versions on cPanel

If you are using specific PHP versions for Kanboard (cPanel allows you to do this), you might have to change the command on step 3 to match this. In my case, I’m using PHP 8.3 specifically for Kanboard, so my cronjob command is: /usr/local/bin/ea-php83 /home/<YOUR_USER>/<YOUR_DOMAIN.com>/cli cronjob >/dev/null 2>&1 (it comes after the /bin/ part).

If you have doubts, check the MultiPHP Manager option on cPanel, and it will show you if you are using a custom one, and which one. E.g.: PHP 8.1 (ea-php81), PHP 8.3 (ea-php83)… what you want is the version between parenthesis.

1 Like