Cron Job which starts at a particular time and runs every 30 mins till the end time [duplicate] - linux

This question already has an answer here:
Run cron job every 2 minutes except the first minute "0" of the first hour "0"
(1 answer)
Closed 3 months ago.
I need to run a python script that starts at 11:30am and then runs every 30 mins till 7PM every day.
The expected included intervals will be: 11:30, 12:00, 12:30, 1:00 ...... 7:00
I have currently defined the Cron Job as:
*/30 11-19 * * * /usr/bin/python3 /mnt/h/WorkSpace/Projects/Backlog_Buddy_Bot/CTest.py
Current Output Intervals: 11:00, 11:30, 12:30, 1:00 ...... 7:00
The problem that I am facing here is this expression includes 11:00 which I dont want. Is there a way I can fix this or is there any alternate scheduler which lets me achieve this?
Disclaimer: I have never run the script till 7:00PM since the starting time has been an issue, so I am not sure if this includes 7:30 as well.

you can use 3 cron job for it.
1-
00,30 12-18 * * * /usr/bin/python3 /mnt/h/WorkSpace/Projects/Backlog_Buddy_Bot/CTest.py
2-
30 11 * * * /usr/bin/python3 /mnt/h/WorkSpace/Projects/Backlog_Buddy_Bot/CTest.py
3-
00 19 * * * /usr/bin/python3 /mnt/h/WorkSpace/Projects/Backlog_Buddy_Bot/CTest.py

Related

Cron job periods

I would like to run the cron job every 20 minutes between 9 AM and 11 PM and once an hour after 11 PM until 9 AM.
cron job settings
I created 2 cron jobs for the same script to achieve my goal. Did I do it correctly?
Thank you.
Not really. There are two issues:
you run the script also on 23:20 and 23:40
you run the script twice from 09:00 till 23:00 every hour.
The way to do it is:
*/20 9-22 * * * command
0 0-8,23 * * * command
You can validate this using crontab guru

Need Quartz Cron Expression to run scheduler every 4 hours starting at 00:30 am

Quatz cron to run the job at 12:30am, 4:30am, 8:30am, 12:30pm, 4:30pm 8:30pm everyday
Can someone please help with this
The expression you search for is:
0 30 0,4,8,12,16,20 * ? * /path/to/command
This will run 30 minutes from every hour in list

Using crontab to execute script between 17:00–20:00 for every 10 minutes

I want to send emails to clients every day between 17:00 to 20:00. I want to run my command every 10 minutes in this period.
So the script will be executed 6 times per hour. That's a total of 18 times.
Is this possible with the crontab? How should I write the syntax?
I think this should work:
0/10 17-19 * * * <cmd>
or:
0/10 17,18,19 * * * <cmd>

setup cron tab to specific time of during weekdays

I am trying to setup a cron job on a Ubuntu server. We want the cron job to run the script at certain times of the day and on some specific days of the week. For example, we want to setup a cron job that runs the script with the following sequence:
Execute the script every 2 minutes from 9 am to 2 pm during the weekdays.
This is what I have been able to do so far:
*/2 09-14 * * * /path_to_script
What should I do for the weekdays?
Same as you did for hours:
*/2 09-18 * * 1-5 /path_to_script
0 and 7 stand for Sunday
6 stands for Saturday
so, 1-5 means from Monday to Friday
You state 2pm in your requirement, hour range should end at 14 instead of 18 (which is 6pm).
*/2 9-14 * * 1-5 /path_to_script
man crontab
http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
In fact the last hour you want the script to run is 13:00 to 13:59, so you want:
*/2 9-13 * * 1-5 /path_to_script
meaning the first runtime will be 9:00, then 9:02, and so on until 13:58 which will be the last run as 14:00 is not included.

Cron job question

I want to run a php script every 10 minutes, between the hours of 9:30AM - 4:00PM
I googled before asking, and didn't have any success.
Anyone know how to do this? Or point me in the right direction?
Thank you
Try the following three lines in crontab
0,10,20,30,40,50 10-15 * * * # Every 10 minutes for the hours 10am - 3pm
0 16 * * * # 4pm
30,40,50 9 * * * # and 9:30, 9:40, 9:50
Run it from cron in every 10 minutes, check th date in PHP do nothing if it's outside the range.
*/10 * * * * /usr/bin/php /path/to/your/script.php

Resources