'execute crontab twice daily at 00h and 13:30
i want to execute a script twice daily at 00:00 and 13:30 so i write :
0,30 0,13 * * *
it seems wrong for me, because like this, the script will fire at 00:00 , 00:30 , 13:00 and 13:30. Any idea ?
Solution 1:[1]
Try this-: 00 01,13 * * *
it will run at 1 A.M and 1 P.M
Solution 2:[2]
You can not do that with cron on a single line. You have to create 2 separate lines like so:
# Will run "YourCommand" at 00:00 every day of every months
#Min Hours D of the M Month D of the Week Command
0 0 * * * YourCommand
# Will run "YourCommand" at 13:30 every day of every months
30 13 * * * YourCommand
Or as a single line you can run a command every x hours, like so:
# Will run "YourCommand" every 12 hours
0 */12 * * * YourCommand
Solution 3:[3]
Try this out: 0 6,18 * * *
it will run at minute 0 past hour 6 and 18
Or you can try it out on cronguru
Solution 4:[4]
try ...
00,30 00,13 * * * [ `date +%H%M` == 1330 ] || [ `date +%H%M` == 0000 ] && logger "its time"
Solution 5:[5]
30 0,13 * * * somecommand.sh
This is just purely an example, but you will see that this is a cron entry that will run at 0:30AM and then 1:30PM (13 is 1 in military time). Just comma separate the hours, or comma separate whatever section of the cron.
Solution 6:[6]
Try this out:
0 1,13 * * *
What the above code means:
Cron will run at minute 0 past hour 1 and 13
Sharing a screenshot from crontab.guru
Solution 7:[7]
try this,
0 10 9/12 ? * *
At second :00, at minute :10, every 12 hours starting at 09am, of every day
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Baby Groot |
| Solution 2 | |
| Solution 3 | Nimish |
| Solution 4 | |
| Solution 5 | David Jeffery |
| Solution 6 | Ankit Jindal |
| Solution 7 | malinda sanjaka |

