I want to create a cron expression to run every friday starting from 25th October at 01:00 AM. Here is the expression I came up with but it is giving error. Kindly help.
0 0 1 25/1 10 6
1
As cron does not directly support start running on a specified date, you can run the cron every Friday at 1 AM and check if the date is on or after 25th October inside your script. Expression to run the script every Friday at 1 AM is as follows.
0 1 * * 5
An example code to check if the date is on or after 25th October in php is as follows.
<?php
$targetDate = new DateTime('2023-10-25');
$currentDate = new DateTime();
if ($currentDate >= $targetDate) {
// Run your logic
} else {
exit();
}
?>