I am on hostinger and i’m trying to setup cron job for my app integrated with WordPress but i am getting the following error:
Some characters are not allowed for cron job command
Anybody know to solve such issue? Thanks.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In some hosting like hostinger, cron jobs with special symbols in the syntax will require you to make a bash (.sh) file which would support any form of cron job needed.
A cron job that would execute a bash file looks like this:
*/5 * * * * /bin/sh /path/to/shell/script.sh
And the bash.sh files contents should look like this example:
#!/bin/sh/usr/bin/php/home/u234927279/public_html/sendy/scheduled.php > /dev/null 2>&1 cron:run
The first part
#!/bin/shindicates this is a Bash file that will be opened by the cron.
The second part loads the php libraries:
The third part is the cron job that otherwise did not work because of the special characters.
cron:runexecutes the cron job inside the file every time the file is opened.
Once you have created the file with your cronjob in it, simply create a simple cronjob that points to the new .sh file.
I hope that helps.
Nice. been trying to figure this out this week. one of my sites is on hostinger and we needed to setup cron job for an add-on we use for email marketing. thanks for sharing this solution aldinlapinig. It worked for me.
Please help out. My project is based on Laravel, hosted on Hostinger.
Is there any other way I need to write this in my script file? I need to set up a cron job scheduler using laravel.
#!/bin/sh/usr/bin/php/home/path_to_project && php artisan schedule:run >> /dev/null 2>&1
It should be the same process since this will be setup and run in your host / server.
this works for me /usr/bin/php/home/path_to_project/artisan schedule:run