Presentation is loading. Please wait.

Presentation is loading. Please wait.

I Hate Cron Jobs J.A. Hourclé - 2015 DC-Baltimore Perl Workshop.

Similar presentations


Presentation on theme: "I Hate Cron Jobs J.A. Hourclé - 2015 DC-Baltimore Perl Workshop."— Presentation transcript:

1 I Hate Cron Jobs J.A. Hourclé - 2015 DC-Baltimore Perl Workshop

2 I <3 cron

3

4

5 I </3 cronjobs

6

7

8

9

10 Problems: I have no idea which of these messages are important. Routine output looks the exact same as a critical error You start to ignore those cronjobs (like clamAV) that generate messages every day. I have no idea which of these messages are important. Routine output looks the exact same as a critical error You start to ignore those cronjobs (like clamAV) that generate messages every day.

11 Solution: If the cron job doesn’t generate output, it won’t trigger an e-mail.

12 Problem #2: This assumes that it sends to STDERR when something goes wrong. And that there’s enough context in STDERR to debug the problem You’ve just trashed whatever other output may have been useful This assumes that it sends to STDERR when something goes wrong. And that there’s enough context in STDERR to debug the problem You’ve just trashed whatever other output may have been useful

13 Solution #2 Capture output, only display on error

14 Solution #2.1 Capture output, only display on error

15 Problems #3-5: Programs that only write to STDOUT When the absense of output is the error. Trying to find the actual error in really spammy commands like rsync Programs that only write to STDOUT When the absense of output is the error. Trying to find the actual error in really spammy commands like rsync

16 Solution #3:

17

18 Problem #6 The ‘stuck’ cronjob: Every hour, for the last week, cron jobs have been starting but not completing. The ‘stuck’ cronjob: Every hour, for the last week, cron jobs have been starting but not completing.

19 Problem #n (insert problem here)

20

21 Use Case #1 Only report if output on STDERR Otherwise, supress STDOUT (default) disable with --ignore-stderr and --ignore-stdout=0 or --verbose or use --merge Only report if output on STDERR Otherwise, supress STDOUT (default) disable with --ignore-stderr and --ignore-stdout=0 or --verbose or use --merge

22 Use Case #2 Only report if non-zero status (default) --ignore-return to disable reporting of non-zero status Only report if non-zero status (default) --ignore-return to disable reporting of non-zero status

23

24

25 Use Case #3: Report if a process runs too long --timer=(seconds) --timeout=(seconds) Report if a process runs too long --timer=(seconds) --timeout=(seconds)

26

27

28

29

30 Use Case #4 Prevent new jobs if an older job is still running --once --ignore-once if you don’t want this to automatically be reported as an error --name to set the lockfile name Prevent new jobs if an older job is still running --once --ignore-once if you don’t want this to automatically be reported as an error --name to set the lockfile name

31

32

33 Use Case #5 Kill old instances if still running before starting the new job --once=2 Kill old instances if still running before starting the new job --once=2

34 Use Case #6: Debugging a cron job Dump %ENV before running --verbose=2 : always generate a message --verbose=3 : dumps %ENV Debugging a cron job Dump %ENV before running --verbose=2 : always generate a message --verbose=3 : dumps %ENV

35

36 Use Case #7 Highlight what the error is --lines=(regex) for ‘known good’ lines. Highlight what the error is --lines=(regex) for ‘known good’ lines.

37

38

39

40

41 Use Case #8 Don’t report if the expected output --lines=(regex) optional and repetitive items --template=(regex) must be present Don’t report if the expected output --lines=(regex) optional and repetitive items --template=(regex) must be present

42

43

44 Config file support --file=(path_to_YAML) any command line args override options set in the file --file=(path_to_YAML) any command line args override options set in the file

45

46

47 Doesn’t do everything

48 Doesn’t: Report before the program ends

49 Doesn’t: Generate its own e-mail So we could change the subject line on success or failure see App::CronJob or change the recipient list based on sucess/fail, or specific error states. Generate its own e-mail So we could change the subject line on success or failure see App::CronJob or change the recipient list based on sucess/fail, or specific error states.

50 Doesn’t: Track success/failrate only report (x) failures in a row or (y) failures per (time) Track success/failrate only report (x) failures in a row or (y) failures per (time)

51 Doesn’t: Limit resources see Process::Govern Limit resources see Process::Govern

52 Helper script

53 Problem: Not released

54 Solar Dynamics Observatory (SDO) Atmospheric Imaging Assembly (AIA) 171Ångstrom ; 2010/07/08 17:45:48UT ; 2x2 binned Solar Dynamics Observatory (SDO) Atmospheric Imaging Assembly (AIA) 171Ångstrom ; 2010/07/08 17:45:48UT ; 2x2 binned


Download ppt "I Hate Cron Jobs J.A. Hourclé - 2015 DC-Baltimore Perl Workshop."

Similar presentations


Ads by Google