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 ...
Related
The below cronjob is not working, although the task itself is working when I manually run it using php artisan q:calc .
I just added the path for php and artisan files as shown below, and pasted the command in the terminal.
Am I missing something ?
* * * * * /usr/bin/php /var/www/html/sharp/artisan schedule:run >> /dev/null 2>&1
That command is a cron entry, not something you run in terminal.
For example, under the specific user you would run (depending on your environment):
$ crontab -e
And paste the above to the crontab file.
You can learn more in the docs:
https://laravel.com/docs/master/scheduling
Or by researching how to add cron entries for your specific operating system.
I've set up crontab on my AWS-EC2 instance to hit the Laravel scheduling endpoint every minute via the root account using sudo crontab-e:
* * * * * php ~/htdocs/artisan schedule:run >> /dev/null 2>&1
However, despite to the cron logs showing it is indeed running every minute:
Jan 26 12:02:01 ip-172-31-28-116 CRON[5057]: (root) CMD (php ~/htdocs/artisan schedule:run >> /dev/null 2>&1)
the job itself isn't executing.
Running the command php ~/htdocs/artisan schedule:run >> /dev/null 2>&1 straight up triggers the job and works.
I'm really struggling with what is going wrong here, am I missing something?
So, I failed to heed the cron output "No MTA installed, discarding output" - Upon installing an MTA (postfix, via sudo apt-get install postfix), it turned out that for the cronjob, php wasn't findable.
Changing the command to use the output of which php to:
/opt/bitnami/php/bin/php /home/bitnami/htdocs/artisan schedule:run
is now working.
Thanks for your help!
Use absolute paths when adding cron entries. ~/htdocs/artisan that should be set using the full path to your application root directory.
It works when you manually run the command because your environment is set accordingly. Not the case when adding cron entries using sudo.
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
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.
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.