Godaddy Cron Job Running every seconds in cpanel - codeigniter

I need to load a file every seconds, which means, there is not a determinate time of the day.
I am using cPanel to run the CronJob and the task (the wget) is already working fine and I am just having trouble with the time schedules.
I have tried:
Minute Hour Day Month Weekday
*/1 * * * *

running every minute:
Minute Hour Day Month Weekday
* * * * *
it seems a bit odd why you run it every second. Cron job cannot be used to schedule a job in seconds interval. i.e You cannot schedule a cron job to run every 1 seconds. The alternative is to write a shell script that uses ‘sleep 1′ command in it.
$ cat every-1-second.sh
#!/bin/bash
while true
do
/home/ramesh/backup.sh
sleep 1
done

Related

Hourly cron Job Excuting 60 times

I am trying to send an email hourly using the Task scheduler in (laravel) framwork,
the command I am typing in the kernal.php:
$schedule->command('cron:activeUsers')->hourly()->withoutOverlapping();
than put the following in crontab -e:
cd /testEmail && php artisan schedule:run >> /dev/null 2>&1
but I am getting like 60 or even 100 email instead of one,
I put some logs to see what is happening:
the cron job is excuting and sending email on the first 60 second of the first minute of each hour like the following for example:
12:00:00
12:00:01
12:00:02
12:00:03
12:00:04
12:00:05
.
.
12:00:59
how I can prevent the cron job to be excuted like this ? I want the cron job to be excuted only once each hour.
Am I using the wrong method to send the email?
The schedule:run command is supposed to be called every minute (as fast as CRON allows), like so:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
See https://laravel.com/docs/9.x/scheduling#running-the-scheduler
Then, your schedule() function in app/Console/Kernel.php defines the interval for each of your tasks, so your ->hourly() command should execute at the start of every hour.
If it is executing any faster than that, its likely that you somehow happen to call the scheduler more often than once a minute (multiple CRONs maybe for the same command?). Try a debug statement in the schedule() function in app/Console/Kernel.php to see that it actually executes once a minute.
When you put a debug statement inside your actual command (i.e. 'cron:activeUsers'), then you should see that it runs every hour.
59 * * * *
repeat at [Minutes] [Hour] [Day of Month] [Which Month] [Which Week]
use the above value to do it every 60 minutes, If want to check it, you can also use https://crontab.guru/ to verify what exactly you want.
at 59, it tells to redo it every 59 minutes, plus have mentioned already there about the star astreriks for you to test and check along with the url of resource

Scheduler command is not working at midnight in Laravel

I have setup a command to run every Saturday at midnight but it is not working
I write this but not running
$schedule->command('weeklyRewardPoints')->weeklyOn(6, '00:00')->timezone('Asia/Dubai');
then I try this but again not working
$schedule->command('weeklyRewardPoints')->weeklyOn(6, '0:0')->timezone('Asia/Dubai');
Even I tried to run at any specific minute at midnight like this but still not working
$schedule->command('weeklyRewardPoints')->weeklyOn(6, '00:30')->timezone('Asia/Dubai');
It is working successfully any other hour and minutes but not at midnight hour and minutes
this is my cron job
* * * * 6 php /home/path-to-my-project/artisan schedule:run >> /dev/null 2>&1
Taken from the Laravel docs
So, when using Laravel's scheduler, we only need to add a single cron configuration entry to our server that runs the schedule:run command every minute.
the scheduler need cronjob needs to run every minute
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
your scheduler runs every 6 minutes.
You can furthermore write
$schedule->command('weeklyRewardPoints')->weeklyOn(6)->timezone('Asia/Dubai');
and remove the time from weeklyOn as it is predefined with 0:0.

Cron Task scheduled to run only once, but is running every 30 mins

I have cron job scheduled in spring boot to run 11:30PM daily, it ran fine for few days and recently it is triggering each hour at least thrice and runs for 0 seconds. The task is to move data from some DB to MongoDB
The cron time defined is #Scheduled(cron = "0 30 23 * * *")

Cron tasks are not always executed

I have the following cron tasks:
/etc/cron.d/mongo
/etc/cron.d/elastic
These cron jobs only executes scripts located here:
/etc/script/mongo
/etc/script/elastic
These tasks execute every 30 minuts, that's the following cron format:
0,30 * * * *
I don't know why but these tasks aren't executing all times. In 2 hours, for example, they only execute 2-3 times and not 4. These tasks are performing backups, I need to be sure that they execute every 30 minuts.
Why this is happening?
PD: If i execute crontab -e the file is empty, this may cause any problem?

Scheduling a script

I want to schedule a script at different timings on different day but with a single crontab entry. e.g I want to schedule a script like below:
it should run at
30 8-5 * * 1-4 script.sh on mon-thu
and same should run at:
30 11-5 * * 5-6 script.sh on Fri,Sat.
Please suggest how to schedule this in one crontab entry.
You can't.
Just being curious: Is there any advantage in having it into one line, except that it saves you typing "script.sh" twice?

Resources