Laravel cron/schedule monthly() not running - laravel

Laravel 5.8.33
I run 2 schedules, one every 5 minutes and one once a month. The five minues schedule runs perfectly using everyFiveMinutes(). But the monthly schedule monthly() never runs. I also tried monthlyOn(1, '00:15') but still the issue remains.
If I swap out monthly() for everyFiveMinutes() it works no problem.
There are no errors in the log file, it simply doesn't run. Has anybody else had this issue? Is there an alternative request to monthly()?
$logfilename = 'cron_'. now()->format('Y_m_d') . '.txt';
//Push Notification check - RUNS EVERY FIVE MINUTES
$schedule->exec('env -i /usr/local/bin/php72 -f /www/xxxx-xxxx.com/artisan command:pushmessages')->everyFiveMinutes()->appendOutputTo(public_path().'/logs/'.$logfilename);
//End of month stats archive - NEVER RUNS
$schedule->exec('env -i /usr/local/bin/php72 -f /www/xxxx-xxxx.com/artisan command:archivestats')->monthly()->appendOutputTo(public_path().'/logs/'.$logfilename);

I know it's late answer but this could be helpful. it's strange as the syntax is correct and I can think of only 1 reason which is the command itself could you share archivestats command code ?
Here are some steps to follow:
run this command:
$schedule->exec('env -i /usr/local/bin/php72 -f
/www/xxxx-xxxx.com/artisan
command:pushmessages')->monthly()->appendOutputTo(public_path().'/logs/'.$logfilename);
if it works then for sure the problem is in the archivestats command.
create a cron task (from GUI or from the terminal for example but not from laravel) that will run on the server monthly ... checkout this link and this link as well.
if you could share the results of the above steps that will help in detecting what's wrong.

If your first command takes over a minute to run, your second command might never see 00:00 in order to run monthly.
Try changing the order of the jobs so that the monthly task gets opportunity to run at midnight.

Related

After triggering a Jenkins job remotely via a Bash script, when should I retrieve the job id?

I already built a script trigger_jenkins_job.sh which works perfectly fine for now. It’s composed mainly of 3 functions:
input_checkpoint
run_remotejob #: Running Jenkins job remotely using Json api.
sleep 10 #: 10 sec estimated time until pending duration is over
#and Jenkins job start running, i.e. a given slave was
#assigned to run the job.
get_buildID #: Retrieving build state, last build ID and last stable
#build ID using
The problem is I want to get rid of that sleep 10 seconds. And in the same time, I want to be sure before executing the function get_buildID that the remotely- triggered job is actually running on a node.
That way I will be retrieving the triggered job’s id, and not the last one in the queue before triggering that job.
Regarding the Jenkins file of the job, I specified:
agent {
label 'linux-node'
}
So, I guess the question is, I need some how from by bash script, to test if linux-node is running the remotely-triggered job, and if yes I execute the function get_buildID.
Get rid of the sleep command and use the wait command.
If you are triggering Job with tokens,it command itself should return you buildNumber.
Another way could be REST API. Please see "nextBuildNumber" field there (if build is still pending) else "number"

running shell script with windows task scheduler

I currenty have a simple shell script that I created for a linux machine to be run using cron, but now I want to be able to run the file using windows task scheduler. I have tried to get it to work using cron for cygwin, but even after running cron-config successfully and ensuring that the shell script can be executed successfully, for some reason the cron task simply wasn't executing. So I decided to give in and use the windows task scheduler. In order to do this, I looked at the following posts about the issue:
Cgywin .sh file run as Windows Task Scheduler
http://www.davidjnice.com/cygwin_scheduled_tasks.html
in my case, the entry in the "actions" tab of the new task looks like this:
program/script: c:\cygwin64\bin\bash.exe
arguments: -l -c "/cygdrive/c/users/paul/bitcoinbot/download_all_data.sh >> cygdrive/c/users/paul/bitcoinbot/logfile.log 2>&1"
start in: c:\cygwin64\bin
Notice that I redirected the output of the shell script to a log file, so that I should be able to see there whether the program run. Other than that, I simply edited the "trigger" tab to run the task daily, and set the time to a couple of minutes in the fture to see whether it ran successfully.
Alas, when I look at the detailed event history for the task, nothing changes when the trigger time passes. And when I manually "run" the task, the event history seems to add a few different events, but the task is completed within seconds, whereas this task should take over an hour (and it does when the shell script is executed directly from the terminal). And when I look for the log file that should have been created, there is nothing.
Does anyone have any idea what might be the issue here? How can I get my task to run properly at the trigger time, and how can I make sure it does so?
Best,
Paul
EDIT:
here are the pictures showing event history, as per Ken White's request.
Please ignore the fact that it says there are 24 events. These are from multiple separate runs of the task. The events shown here are a complete list of the events triggered by a single run.
EDIT 2:
Regarding my attempts to get cron to work, I have run into the following problem when I try to start the cron service using cygrunsrv. First of all, I tried to start cron by typing
cygrunsrv -I cron -p /usr/sbin/cron.exe -a -D
Now when I type
$cygrunsrv -Q cron
Service: cron
Current State: stopped
Command: /usr/bin/cron.exe
Now, I tried to start the cron service by typing
cygrunsrv -S cron
Cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062:
The service has not been started.
Does anyone hae any idea what this error means? I tried googling it, but couldn't find any answers.

ubuntu cron job stopped working

The cron job used to working well and suddenly stopped working
1 * * * * /usr/bin/python3 /home/roy/update.py
It can still run manually on the command line.
Then I tried to debug it by the following command:
/usr/bin/python3 /home/roy/update.py 2>&1 >> /home/roy/cron_error_report.txt
There is no error shown in the cron_error_report.txt either.
Can anybody help me?
Make sure cron is running
sudo service cron status
I hope my answer can help others. It really take a long time to figure it out.
I moved a file used for my current python program to a shared folder. I exported the shared folder to PYTHONPATH.
So there is no problem while I run the script in the command line. However, cron could not run it. So I have to move the file back to my current folder and the cron starts to work again.

Cron Job with PHP5 CLI and ISP config

I am working on a project under Symfony2, and a dedicated server.
This server got ISP Config Panel.
I want that my cron runs a php-cli command line, integrated in symfony2 (php app/console config:renewalsession ).
My command in PHP-Symfony works really fine. If I run it manually, it does what I want.
But I am blocked with cron jobs. So I did a sh script, who calls the command.
#!/bin/bash
#!/usr/bin/php5
php /var/www/clients/client1/web1/private/app/console config:renewalsession
I set up the cron job, for working in two minutes, I wait, and nothing happen.
I don't know from where it comes ...
So can someone help me ?
Edit :
I got some more informations. My sh script works fine. Problem was coming from how I filled inputs of the cron.
I have to fill a form with "minutes" "hours" "days of month" "months" "days of week" and my command. My command is good.
So the problem come from the rest of inputs.
I want that the cron runs everyday, one time, at 1h am.
So I have filled form this way :
minutes : 0
hours : 1
days of month : *
months : *
days of week : *
What is wrong with those parameters ?
This will run your script at 1AM every day of the month:
0 1 * * * sh /path/to/script.sh

Creating more permanent crontab files

I just recently asked this question: https://stackoverflow.com/questions/6359367/running-a-bash-program-every-day-at-the-same-time
The solution of using crontab -e to create a job worked very well and my script worked fine.
However, I found that once I exited the terminal, that job was deleted. How can I create a job mediated by cron that will work every day at the same regardless of if I exit the terminal or even turn off my computer (assuming my computer is turned back when the cron job is scheduled to execute)
cron is permanent. So the accepted answer given in the linked question would run the script at 7 AM everyday. It has nothing to do with if you are logged in or not.

Resources