Cron Job command not working - php

I have a simple script in my server and I need a cron job to make it run every minute. I am using cPanel to set it. What should I enter in the cron job "command" field? I am newbie with cron job commands, I have tried many different options:
/home/enkaizen/public_html/soporte/wp-content/scripts/index.php
/usr/local/bin/php /home/enkaizene/public_html/soporte/wp-content/scripts/index.php
/usr/local/bin/php -q /home/enkaizene/public_html/soporte/wp-content/scripts/index.php
/usr/bin/php /home/enkaizene/public_html/soporte/wp-content/scripts/index.php
/usr/bin/php -q /home/enkaizene/public_html/soporte/wp-content/scripts/index.php
But none seem to be working. I know my script is correct because when I run it manually it does what it is suppose to do.
For in case it helps, my host is https://www.frenzysolutions.com
Any ideas what can I be doing wrong?

To run php from cron try the f flag
php -f /home/enkaizen/public_html/soporte/wp-content/scripts/index.php
It is best practice to use the full path to the executable when using cron. Unfortunately this is distribution/os dependent but it is probably either /usr/bin/php or /usr/local/bin/php

Are you getting any error with "php -q" command ?
Also you can use curl command instead of php -q to execute your scripts through command line.

Related

Running codeigniter 3 cron job issue

I'm trying to run a codeigniter 3 cron job. If I open the file manually it works through the browser and I find databse updated and emails are sent
https://www.example.com/module_name/controller/method
But not working through a cron job like this every minute on a private server
curl --silent https://www.example.com/module_name/controller/method
Also tried
/usr/local/bin/php /home/username/public_html/index.php module_name controller method
Any idea or other ways to run it?
I'd first go to a terminal and check that your php is actually at /usr/local/bin/php by running:
which php
You mentioned that you'd like to know other ways to run the cron, and I've used wget many times. For you that would look something like:
/usr/bin/wget https://www.example.com/module_name/controller/method -O /dev/null
In most(all?) Linux distros, you're going to open crontab for editing using:
crontab -e
Once in there, just add a line:
* * * * * /usr/bin/wget https://www.example.com/module_name/controller/method -O /dev/null
Do ensure that you have wget available, and it's location by running:
which wget

Can I use wget to run a local file as a cron job using relative path above public_html?

I'm trying to setup a script to run in a cron job, and I want it to run once a day. I'm new to cron jobs, and the ones I have seen so far are only using absolute paths like:
http://example.com/path/to/file.
This is the command I want to do in cpanel:
/usr/bin/wget -O - -q -t 1 /home/account/invest/controllers/cron_controller.php
Would this work? Or is another command better than wget?
The best command is php /home/account/invest/controllers/cron_controller.php.

cron job is not working

Hi I am using justhost web server and trying to set a cron job but it is not producing any output . I am using this command in the cpanel
php -q /home6/username7/public_html/folder/app/cron.php
the name display on cpanel file browser is like home6 . any help will be appreciated . and how to check is this command is right or wrong.thanks in advance
Did you try with this :
Command to run for a PHP5 cron job:
/usr/local/php5/bin/php5 /home/username/public_html/cron.php
Command to run for a PHP4 cron job:
/usr/bin/php /home/username/public_html/cron.php
you should try this. ( give path to php command )
/usr/bin/php -q /home/username/public_html/yourfilename.php
Run a PHP file in a cron job using CPanel

Cannot execute PHP script periodically using crontab on Ubuntu

I want to execute a php script every 5 minutes. I'm using Ubuntu and I followed these steps:
Executed crontab -e from terminal, entered:
*/5 * * * * /usr/bin/php /var/www/test1.php
in the nano text editor, saved it and started the crontab. It gave no errors and said "installing new crontab", but my script is not being executed. I gave the necessary permissions to the files I use in my script, too.
Any help would be greatly appreciated, thanks.
This is what I use for scheduling cron jobs on apache server in cpanel interface :
/usr/bin/php -q /home/domain_name/public_html/cron_test.php
So, you should specify the path to the php executable too, for making the php script work and execute.

Setting FUEL_ENV for a crontab

I'm trying to setup a cron for a task to run under FuelPHP while setting the environment.
/bin/bash FUEL_ENV=development /usr/local/bin/php /home/net/###DIR###/oil refine TaskName 2>&1
However I get the following error everytime.
/bin/bash: FUEL_ENV=development: No such file or directory
I'm not an expert at setting up cron jobs but is there something I am missing here? (The task on it's own run from the command line using the same command works
Here is the fix:
/bin/bash -c "FUEL_ENV=development; /usr/local/bin/php /home/net/###DIR###/oil refine TaskName 2>&1"
For a simpler command line, you can use the env utility:
env FUEL_ENV=development /usr/local/bin/php ...

Categories