Magento Cron Job Problem - cron

In Magento I have set the cron job to run every minute and I also created a cron job in the plesk control panel because the magento setup wasn't working for me.
So I created a cron job as follows:
/usr/bin/php -f /home/dealscou/public_html/cron.php
This works for me most of the time when the cron job is set to 1 minute.
If I create a cron job for any other amount of time, it does not work.
I am really stuck on this and my customer is getting ticked that I can't fix it.
Any help would be appreciated.
Kathy

You should run the cron from the cron.sh file and not directly from the cron.php file

Related

Magento 2.3: Cron job is only working when I run the cron command manually

I have created a cron job and its only working when I run the below command:
php bin/magento cron:run
But the cron should run automatically. What Could be the issue and why the cron is not running automatically in my case?
Could anyone please help me and guide on this?
Cronjobs in Magento are separate from the cronjobs ran on the server. A cronjob in Magento can't run without a cronjob on the server.
If you want cronjobs in Magento to run automatically you'll have to add a cronjob on the server.
* * * * * bin/magento cron:run
I do not recommend copy-pasting the above as a cronjob on your server, it does for example not log any output.
If you want a more detailed explanation about the workings of cronjobs in Magento I recommend the article in Magento DevDocs below.
https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-cron.html

Run a command every 5 minutes and stop it at the end of that time

I have to run NodeJS application which has to run uninterruptedly, but I need to stop it and restart it every 10 minutes.
I'm Working on a dedicated Ubuntu 18.04 machine.
I have read something about cron but I don't know well how it works. Does it stop the command that was run with it?
You can use forever to run the application, and set up a cron job to restart it in forever every five minutes. As a bonus, forever will also restart it for you if it fails in between cron job executions.
In my knowledge, the cron doesn't stop the command that had run before, but you could add the logic to do that check in your application.
Here you can find an article that shows some solutions to prevent duplicate cron job executions.

can I schedule an ansible playbook to run at a certain time everyday

I have an ansible playbook in yaml to start a service in a host server.
can I schedule it to run at a certain time everyday?
Also will cron work for it?
ansible-playbook is a command, like cp or any other.
So yes, you can add it as cron job and set desired schedule for it.

Cron job in centos

I have few more doubt in crontab jobs
My scenario: I have put two cron jobs at 23 Hrs every day 1 job is move files to another directory & the 2nd job is upload this file to ftp server.
How to get last ran time cron job & last run result( if succeeded or failed )details in centos ?
How to view at present running cron job in centos ? ( example : 1st job starting at 23 Hrs & the 2nd job starting at 23:30 Hrs and ending after 5 mins { assuming 1st cron job should be completed after 30mins , I want to view this job running details in live.(30 mints duration ) })
Log or live view
Note: Running as root user privilege.
Thanks
G Dhamu
You can watch the logs of jobs that were ran by cron under /var/log/cron (default location)
You cannot have a "live view" since you're not the one who's running it... What you can do, is tail cron-log or have your program write its output to a different log and open a screen that tails it.
How to upgrade apache 2.4.6 to 2.4.16 on CentOS -7..
‪#‎cat‬ /etc/redhat-release
CentOS Linux release 7.1.1503 (Core))

Is there any time restriction for cloud9.ide?

I'm trying to run quick php update over cron tab on Cloud9 IDE.
Here is my crontab -l:
*/2 * * * * php /home/ubuntu/workspace/public_html/updater.php
I also tried to use data from "whereis php" instead of simple php, but still nothing.
And here comes my question. Is there any time restriction eg. 1 hour minimum for cron in C9?
Or maybe I'm doing something wrong.
Tried to restart cron already.
Cron daemon is not started. You have to start it manually. Your output from px -aef | grep cron shows that grep is running not cron.
sudo cron start
Please read here, from the C9 FAQ:
We currently do not support cron jobs within Cloud9 workspaces. The way to proceed would be to get a Cloud9 premium plan which allows you to create SSH workspaces
You may need to run the cron daemon to make the cron job run ("service cron start"). However Cloud9 workspaces are paused when they are inactive so it will only run when you're actively logged into the IDE.

Resources