Skip to content

Instantly share code, notes, and snippets.

@unionx
Last active August 29, 2015 14:08
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 unionx/6f77bf7933674f174794 to your computer and use it in GitHub Desktop.
Save unionx/6f77bf7933674f174794 to your computer and use it in GitHub Desktop.
Sample script for using plan to write cron files
#!/usr/bin/env python3
from plan import Plan
import argparse
cron = Plan()
# write the cron jobs here:
cron.command("/usr/bin/pganalyze-collector --cron", every="5.minute")
cron.command("/bin/date >> /home/unionx/time.txt", every="1.minute")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="show the cron or write it")
parser.add_argument("--check", help="show the cron output", action="store_true")
parser.add_argument("--update", help="update the cron file", action="store_true")
parser.add_argument("--write", help="write a new cron file", action="store_true")
args = parser.parse_args()
if args.check:
cron.run()
elif args.update:
cron.run("update")
elif args.write:
cron.run("write")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment