Mautic Community Forums

.sh script won't run cronjobs

My Mautic version is: 2.15.2
My PHP version is: 7.2.19

My hosting provider’s cronjobs don’t support certain commands like writing cronjobs results to log files (they have their own modified version of cpanel). For example:

php /home/user/ mautic:segments:update > /home/user/ 2>&1 gets me an error that some characters are not supported.

(If I just write php /home/user/ mautic:segments:update everything is fine and the processes are running on mautic).

So their proposed workaround was to write a script for every cronjob and use it as a cronjob. So my scripts are:

/usr/bin/php /home/user/ mautic:segments:update > /home/user/ 2>&1

and so on.

The hosting provider says that the cronjobs/scripts are executed from their side.
(the output of cronjob is:
–2019-09-30 23:40:01-- Resolving (… Connecting to (||:443… connected. HTTP request sent, awaiting response… 200 OK Length: 238 [application/x-sh] Saving to: ‘/dev/null’ 0K 100% 38.1M=0s 2019-09-30 23:40:06 (38.1 MB/s) - ‘/dev/null’ saved [238/238]
so they say the problem is with my scripts. Any ideas what’s wrong? Help needed :slight_smile:

I doubt that is the intended way to invoke the bash script.

php script option

If you are interested in adding a PHP interface for running the cron commands, have a look at my repo here:

Once installed, you can browse to this page:

:warning: You need to update the password in the file from mautibot_happy


For using your script in crontab specifically, try this:

*/15 * * * * /home/user/ > /home/user/ 2>&1

Two notes:

  • this assumes that /home/user/ is executable. If not, put bash at the start of the command

bash /home/user/

  • not sure if your provider needs the every 15 minutes part at the beginning.

And in your script, remove the output redirection:

/usr/bin/php /home/user/ mautic:segments:update


thank you @virgilwashere for your reply

well, that’s what I was told to use in the command line to invoke the script… and from the output file support says it’s working from their side…

I didn’t plan to use crontab file but to use hosting providers interface for adding cronjobs (failed when I tried to ad logging :frowning: ), then I tried to use script for that (failing up till now :frowning: ) , so the third option could be to use crontab file as you say, and if that fails, to change provider who uses a normal cpanel…

Yes, scripts are executable, but if I’ll use crontab though, I don’t think I need to use my scripts? I’ll type the php commands directly to the crontab…

Not sure if I got that:

you mean to remove adding the log file ?
“/home/user/ 2>&1”

found the issue. Yes, the problem was with hosting support giving the wrong instructions to invoke the script and saying that everything is ok from their side… that says a lot about their support :poop::…

1 Like