Skip to content

Instantly share code, notes, and snippets.

@CodyKochmann
Created June 18, 2021 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodyKochmann/74b35b67b528eae278dee9673158b745 to your computer and use it in GitHub Desktop.
Save CodyKochmann/74b35b67b528eae278dee9673158b745 to your computer and use it in GitHub Desktop.
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