Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
functions to generate random cron schedules for different common intervals in python
#!/usr/bin/env python
# Author: Cody Kochmann
# Created: 2021-06-18
# License: MIT
from random import randint
class cron():
@property
def hourly(self):
return f'{randint(0, 59)} * * * *'
@property
def daily(self):
return f'{randint(0, 59)} {randint(0, 23)} * * *'
@property
def weekly(self):
return f'{randint(0, 59)} {randint(0, 23)} * * {randint(0, 6)}'
@property
def monthly(self):
return f'{randint(0, 59)} {randint(0, 23)} {randint(0, 27)} * *'
@property
def yearly(self):
return f'{randint(0, 59)} {randint(0, 23)} {randint(0, 27)} {randint(0, 11)} *'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment