Last Day of Month Handling #688
Replies: 4 comments 2 replies
-
This feature is coming natively in Cronicle v2. There is a hack you can use in Cronicle v1 to achieve the effect. Use the Shell Plugin for your event, and add this code to wrap your own command: #!/bin/bash
# Get today's date and the date of the next day
today=$(date +%Y-%m-%d)
next_day=$(date +%Y-%m-%d -d "$today + 1 day")
# Extract the month from both dates
month_today=$(date -d "$today" +%m)
month_next_day=$(date -d "$next_day" +%m)
# Compare the months
if [ "$month_today" != "$month_next_day" ]; then
echo "Today is the last day of the month."
###
# Execute your command here
###
else
echo "Today is not the last day of the month."
fi Then set your event to run on the 28th, 29th, 30th and 31st days of the month. On the "real" last day of the month, your command will be executed. On the other days, the job will run, but it will just exit without doing anything. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
All you need to do is only run if 'tomorrow' is the first of the month if [ $(date --date "tomorrow" +%d) -eq 1 ]; then |
Beta Was this translation helpful? Give feedback.
-
Hey Joseph!
This is the only way I could figure to reach out, but I know you've wanted
to see this bug happening to fix it. Here ya go:
https://tasks-production.streampay.streamlinepayments.com/
…On Mon, Dec 4, 2023 at 10:52 PM Joseph Huckaby ***@***.***> wrote:
This feature is coming natively in Cronicle v2.
There is a hack you can use in Cronicle v1 to achieve the effect. Use the Shell
Plugin
<https://github.com/jhuckaby/Cronicle/blob/master/docs/Plugins.md#built-in-shell-plugin>
for your event, and add this code to wrap your own command:
#!/bin/bash
# Get today's date and the date of the next day
today=$(date +%Y-%m-%d)
next_day=$(date +%Y-%m-%d -d "$today + 1 day")
# Extract the month from both dates
month_today=$(date -d "$today" +%m)
month_next_day=$(date -d "$next_day" +%m)
# Compare the monthsif [ "$month_today" != "$month_next_day" ]; then
echo "Today is the last day of the month."
###
# Execute your command here
###
else
echo "Today is not the last day of the month."fi
Then set your event to run on the 28th, 29th, 30th and 31st days of the
month. On the "real" last day of the month, your command will be executed.
On the other days, the job will run, but it will just exit without doing
anything.
Hope this helps.
—
Reply to this email directly, view it on GitHub
<#688 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJOT6YBVYATN3IC2WOAI6VLYH2LA3AVCNFSM6AAAAABAG5I25SVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TONJZHE3TE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Sorry sent too soon.
This is in reference to this bug:
#523
…On Wed, Feb 5, 2025 at 8:19 PM denjr221 ***@***.***> wrote:
Hey Joseph!
This is the only way I could figure to reach out, but I know you've wanted
to see this bug happening to fix it. Here ya go:
https://tasks-production.streampay.streamlinepayments.com/
On Mon, Dec 4, 2023 at 10:52 PM Joseph Huckaby ***@***.***>
wrote:
> This feature is coming natively in Cronicle v2.
>
> There is a hack you can use in Cronicle v1 to achieve the effect. Use the Shell
> Plugin
> <https://github.com/jhuckaby/Cronicle/blob/master/docs/Plugins.md#built-in-shell-plugin>
> for your event, and add this code to wrap your own command:
>
> #!/bin/bash
> # Get today's date and the date of the next day
> today=$(date +%Y-%m-%d)
> next_day=$(date +%Y-%m-%d -d "$today + 1 day")
> # Extract the month from both dates
> month_today=$(date -d "$today" +%m)
> month_next_day=$(date -d "$next_day" +%m)
> # Compare the monthsif [ "$month_today" != "$month_next_day" ]; then
> echo "Today is the last day of the month."
>
> ###
> # Execute your command here
> ###
> else
> echo "Today is not the last day of the month."fi
>
> Then set your event to run on the 28th, 29th, 30th and 31st days of the
> month. On the "real" last day of the month, your command will be executed.
> On the other days, the job will run, but it will just exit without doing
> anything.
>
> Hope this helps.
>
> —
> Reply to this email directly, view it on GitHub
> <#688 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AJOT6YBVYATN3IC2WOAI6VLYH2LA3AVCNFSM6AAAAABAG5I25SVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TONJZHE3TE>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
-
Does anyone have a method for handling the creation of an event that is to run on the last day of the month? In our current setup, our only option seems to be to create 3 schedules if the user wants their schedule to run on the last day of the month. I expect a Cronicle event set to run monthly on the 31 to run only on months that have a 31st. All ideas welcome and appreciated!
Beta Was this translation helpful? Give feedback.
All reactions