Cron job executed, but shouldn't - cron

I have a cronjob with this configuration:
Minute: 0
Hour: 10
Day: 23
Month: *
Weekday: 0,6
I don't know why, today Saturday 25 of April of 2015, has executed.
My intention was to run only 23th of every month, on weekend days at 10 AM.
Thanks

Related

Running every 15 min at 10th min of the hour except between until 10:30 to 11:00 and 22:30 to 23:00

How to configure a cron job to run every 15 mins starting at the 10th min of the hour, but it shouldn't run between 10:30 to 11:00 and 22:30 to 23:00.
I have figured out the logic to run it every 15 mins starting at the 10th min of the hour, but it stops from 10:00 to 11:00 and 22:00 to 00:00
The cron expression that I have built is:
10/15 0-10,11-22 * * *
A modified cron expression where the job runs every 15 min starting at the 10th min of the hour, but doesn't run between 10:30 to 11:00 and 22:30 to 23:00

get full date of a specific day of the current week with GNU date

Is there a way to get the date of Friday of the current week regardless whether it is in the future or past from current day ?
For example, today is 2021-07-10 so Friday of the current week would be one day ago. But if today was 2021-07-05 Friday of the current week would be four days in the future.
I am aware that with date utility you can get either last Friday or the coming Friday with :
date --date="last Friday" and
date --date="next Friday"
is there a way to get the date of Friday of the current week without complicated logic ?
The only way I know how to do what you want is to do something like the following
date -d "next monday - $(($(date +%u) -1)) days"
Of course, there are side issues such as which day is the start of the business week (it varies), etc.
Here is a simple script to print out a week's dates:
#!/bin/bash
for DAY in monday tuesday wednesday thursday friday saturday sunday
do
# date -d "next $DAY - $(($(date +%u) - 1)) days"
date -d "next $DAY - $(date +%u) days
done
It produces the following output based on today's date:
Mon Jul 5 12:00:00 AM PST 2021
Tue Jul 6 12:00:00 AM PST 2021
Wed Jul 7 12:00:00 AM PST 2021
Thu Jul 8 12:00:00 AM PST 2021
Fri Jul 9 12:00:00 AM PST 2021
Sat Jul 10 12:00:00 AM PST 2021
Sun Jul 11 12:00:00 AM PST 2021

Running a cron at 4 am and 4 pm

The following cron expression cron(0 14 ? * MON-FRI *) basically runs something 4:00 pm from Monday to Friday.
I am wondering if it is possible to modify the expression so I can run something at 4:00 am and 4:00 pm every Monday to Friday.
Use this crontab line to run command_name at 4:00 and 16:00 (4 AM and 4 PM) Monday-Friday:
0 4,16 * * 1-5 command_name
From crontab manual:
The time and date fields are:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sunday, or use names)
Your Cron job description looks different from the general crontab. But to give you an idea of how to achieve what you're looking for:
Edit cron-table. Choose your editor.
crontab -e
Add 2 lines cron jobs.
* 4 * * 1-5 /usr/bin/...# Your command goes here 04:00 am.
* 16 * * 1-5 /usr/bin/...# Your command goes here 04:00 pm.
4PM (16:00): 0 16 * * MON-FRI
See crontab guru
"At 16:00 on every day-of-week from Monday through Friday.”
4AM &4 PM (4:00 & 16:00): 0 4,16 * * MON-FRI
See crontab guru
β€œAt minute 0 past hour 4 and 16 on every day-of-week from Monday through Friday.”

Cron job should run every 15 minutes , but it should NOT run between 9:00 (AM) to 10:00 (AM)

How to run a Cron job every 15 minutes , but it should NOT run between 9:00 (AM) to 10:00 (AM).
You may try:
* 0,15,30,45 0-9,10-23 * * ?
The above CRON says to run on the hour, 15, 30, and 45 minutes past the hour, from midnight to 9am, and from 10am to midnight. This excludes 9am-10am which was your requirement.

Scheduling scripts with variable frequency

I want to run a python script on a ubuntu 14.04 server with following frequency:
Monday to Friday:
From 0800 hrs to 1600 hrs: Run once every hour
From 1600 hrs to 2300 hrs: Run once every 30 minutes
Saturday and Sunday:
From 0800 hrs to 2300 hrs: Run once every two hours
At other times, don't run
Is this possible with cron? If not, can anybody suggest some alternative?
As suggested in the comments, adding these cron entries will do:
(Lines starting with # are comments)
# monday to friday, 8 am to 4 pm, once every hour
0 8-16 * * 1-5 <command>
# monday to friday, 4 pm to 10 pm, twice every hour
0,30 17-22 * * 1-5 <command>
# saturday to sunday, 8 am to 11 pm, once every hour
0 8-23 * * 0,6 <command>

Resources