Reputation: 1
So basically I recently went from cpanel hosting to hostinger. Now I had a cron job that ran easily on cpanel. * * * * * wget --spider -O - https://social.yoursite.in/api_provider/cron/order >/dev/null 2>&1
, setting this cron was easy just paste and it ran. But now on hpanel I am unable to use the same command to setup cron jobs. It throws an error "Some characters are not allowed for cron job command". On contacting hostinger support, they say I can add these command lines to a Bash script or php script and add the script to cron.
I do not know anything on running scripts but searching a lot on internet and a little help from support team I made a file cron.sh and included these inside the file #!/bin/sh/usr/bin/php/home/u375788432/youbloom.in/public_html/social/ wget --spider -O - https://social.yoursite.in/api_provider/cron/order cron:run >/dev/null 2>&1
still on checking this doesn't actually execute and the functionality I wish to achieve doesn't work.
also if we can put this into a php script that would work too.
Upvotes: 0
Views: 4653
Reputation: 21
in order to use special characters, you need to put your script in a bash files.
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:
#!/bin/sh
/usr/bin/php /home/u123456789/public_html/script/scheduled.php cron:run > /dev/null 2>&1
The first part #!/bin/sh
indicates this is a Bash file that will be opened by the cron.
The second part loads the php libraries: /usr/bin/php
The third part is the cron job that otherwise did not work because of the special characters. cron:run executes the cron job inside the file every time the file is opened
So after you have created your bash file, you can set up your cron in hPanel with the path of your bash file in file manager.
Upvotes: 2