I’m trying to schedule a cronjob to run every 10 minutes during a specific time window, specifically from 4:00 am to 5:30 am. the job should execute at these times:
4:00, 4:10, 4:20, …, 5:10, 5:20, 5:30. what is the best practice to do this?
Looks like it doenst like 2 schedule in sinngle cron with coma
I would suggest to try with 2 different job
or
Cron schedule: “*/10 4-5 * * *” # Covers 4:00 AM to 5:59 AM
and add condition check like this.
#!/bin/bash
current_time=$(date +%H:%M)
if [[ "$current_time" > "03:59" && "$current_time" < "05:31" ]]; then
echo "Running job at $current_time"
# Add your job logic here
else
echo "Skipping job at $current_time"
fi