I Hate Cron Jobs J.A. Hourclé - 2015 DC-Baltimore Perl Workshop.
-
Upload
samuel-fletcher -
Category
Documents
-
view
215 -
download
0
Transcript of I Hate Cron Jobs J.A. Hourclé - 2015 DC-Baltimore Perl Workshop.
I Hate Cron JobsJ.A. Hourclé - 2015 DC-Baltimore Perl
Workshop
I <3 cron
I </3 cronjobs
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.
Solution:
•If the cron job doesn’t generate output, it won’t trigger an e-mail.
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
Solution #2
•Capture output, only display on error
Solution #2.1
•Capture output, only display on error
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
Solution #3:
Solution #3:
Problem #6
•The ‘stuck’ cronjob:• Every hour, for the last week, cron jobs
have been starting but not completing.
Problem #n
•(insert problem here)
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
Use Case #2
•Only report if non-zero status•(default)• --ignore-return to disable reporting of
non-zero status
Use Case #3:
•Report if a process runs too long•--timer=(seconds)
•--timeout=(seconds)
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
Use Case #5
•Kill old instances if still running before starting the new job
• --once=2
Use Case #6:
•Debugging a cron job• Dump %ENV before running
•--verbose=2 : always generate a message
•--verbose=3 : dumps %ENV
Use Case #7
•Highlight what the error is•--lines=(regex) for ‘known good’
lines.
Use Case #8
•Don’t report if the expected output•--lines=(regex)• optional and repetitive items
•--template=(regex)• must be present
Config file support
•--file=(path_to_YAML)
•any command line args override options set in the file
Doesn’t doeverything
Doesn’t:
•Report before the program ends
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.
Doesn’t:
•Track success/failrate• only report (x) failures in a row• or (y) failures per (time)
Doesn’t:
•Limit resources• see Process::Govern
Helper script
Problem:Not released
Solar Dynamics Observatory (SDO)Atmospheric Imaging Assembly (AIA)
171Ångstrom ; 2010/07/08 17:45:48UT ; 2x2 binned