Last active
August 29, 2015 14:08
-
-
Save unionx/6f77bf7933674f174794 to your computer and use it in GitHub Desktop.
Sample script for using plan to write cron files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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