Anyway, that sleep for for example code only.
Imagine the code that reads the following control file,
executing things as they show up in a variety of
directories.
I needed the catching of the return values to keep
a history of failures and raise alarms if they hit
a certain threshold in a certain timeframe.
Different dirs have different sleep cycles, so I sleep
on the shortest one and compare to see if I've slept
enough for the longer ones.
Note: Ignore the crypt commands, they are play placeholders.
\n[GLOBALS]\n#\n# Set a single section here in order to test \n# the setup of a new section while the main\n# sweep is still running. \n#\nsection_to_process=Customer_B_crypt_dir\n#\n#\ndaemon=0\nverbose=1\ntime_stamp=1\n#\n# It is up the the called program to handle \n# error messages, recovery, etc. since the \n# sweep program simply does not have application\n# specific awareness to be able to give error\n# messages of any real value.\n#\n# But if enough things go wrong in a certain\n# period (determined on a dir group by dir group basis),\n# there is probably a serious problem SOMEWHERE.\n#\n#\nemail_on_failure=broom@somewhere.com\n#\n# Sequential by default\n#\nmax_parallel_jobs_per_dir=1\n#\n# Kill myself if this file arrives\n#\nabort_file=/tmp/sweep_abort.flag\n#\n# All dirs will be based from here in the test\n#\nbase=/home/broom/sweep\nlog_dir={{base}}/logs\nstdout={{log_dir}}/stdout.log\nstderr={{log_dir}}/stderr.log\n#\n# Default amount of time to sleep between\n# dir sweeps\n#\nsleep_time=5\nglobal_email=broom@somewhere.com mgraham@somewhere.com\noperations_email=operations_manager@somewhere.com\n#\n# These are default in the program\n#\n# Match everything\n#match_pattern=.*\n# Except things that start with period\n#exclude_pattern=^\\.\n#\n\n#\n# {{file}} is special, it will be subtituted with\n# the new file. All other are must be defined before used\n#\n#\n################################################################################\n#\n#\n[Customer_B_crypt_dir]\n#\n#\n################################################################################\n\nsuccess_email=customer_b_csr@somewhere.com {{global_email}}\nfailure_email={{success_email}} {{operations_email}}\ndir_group=Crypt\ncust=cust_b\nsource={{base}}/{{cust}}/q\ndest={{base}}/{{cust}}/inprocess\ndone={{base}}/{{cust}}/done\nerror={{base}}/{{cust}}/bad\nlog_file={{base}}/logs/{{cust}}.log\nnice=5\nuser=broom\n#\ncommand=sleep 10;rm -f /tmp/test.tmp;set >/tmp/test.tmp;set;\\\nps -eo "%n %U %u %p %y %x %c";echo {{file}} --process={{dest}} \\\n--done={{done}} --error={{error}} --log={{log_file}}\n#\nmax_parallel_jobs_per_dir=3\nstdout={{log_dir}}/cust_b.stdout.log\nstderr={{log_dir}}/cust_b.stderr.log\n\n\n################################################################################\n#\n#\n[Customer_A_crypt_dir]\n#\n#\n################################################################################\n\ndir_group=Crypt\nexclude_pattern=(^\\.|README|\\.key\\.asc$)\nsuccess_email=customer_a_csr@somewhere.com {{global_email}}\nfailure_email={{success_email}} {{operations_email}}\ncust=cust_a\nsource={{base}}/{{cust}}/q\ndest={{base}}/{{cust}}/inprocess\ndone={{base}}/{{cust}}/done\nerror={{base}}/{{cust}}/bad\nlog_file={{base}}/logs/{{cust}}.log\n#\ncommand=echo {{file}} --process={{dest}} \\\n--done={{done}} --error={{error}} --log={{log_file}}\n#\nsleep_time=60\nmax_parallel_jobs_per_dir=1\nmax_load=3\nstdout={{log_dir}}/cust_a.stdout.log\nstderr={{log_dir}}/cust_a.stderr.log\n\n\n#\n# The following FTP vars should supply everything required for\n# a generic FTP set of scripts. If you find yourself hardcoding\n# ANYTHING in the script, back-off and put the var in here.\n#\n################################################################################\n#\n#\n[West_FTP_Server]\n#\n#\n################################################################################\n#\n# Set the disable flag to turn off processing\n# of a particular directory\n#\ndisable=1\n\ndir_group=ftp_internet\nsuccess_email=west_ftp_production_person@somewhere.com {{global_email}}\nfailure_email={{success_email}} {{operations_email}}\nftp_base=west_ftp\nsource={{base}}/{{ftp_base}}/q\ndest={{base}}/{{ftp_base}}/inprocess\ndone={{base}}/{{ftp_base}}/done\nerror={{base}}/{{ftp_base}}/bad\nlog_file={{base}}/logs/{{ftp_base}}.log\nnice=5\nuser=ftp_production_user\n#\n# Note: This file MUST be root read-only!\n#\nftp_server=ftp3.somewhere.com\nftp_user=user_a\nftp_pass=pass_a\n#\ncommand=ftp_via_sweep.sh {{file}} \n#\nmax_parallel_jobs_per_dir=1\nstdout={{log_dir}}/{{ftp_base}}.stdout.log\nstderr={{log_dir}}/{{ftp_base}}.stderr.log\n\n\n################################################################################\n#\n#\n[Central_FTP_Server]\n#\n#\n################################################################################\ndisable=1\n\ndir_group=ftp_internet\nsuccess_email=central_ftp_production_person@somewhere.com {{global_email}}\nfailure_email={{success_email}} {{operations_email}}\nftp_base=central_ftp\nsource={{base}}/{{ftp_base}}/q\ndest={{base}}/{{ftp_base}}/inprocess\ndone={{base}}/{{ftp_base}}/done\nerror={{base}}/{{ftp_base}}/bad\nlog_file={{base}}/logs/{{ftp_base}}.log\nnice=5\nuser=ftp_production_user\nftp_server=dfwfap01.somewhere.com\nftp_user=user_b\nftp_pass=pass_b\n#\ncommand=ftp_via_sweep.sh {{file}} \n#\nmax_parallel_jobs_per_dir=1\nstdout={{log_dir}}/{{ftp_base}}.stdout.log\nstderr={{log_dir}}/{{ftp_base}}.stderr.log\n\n\n################################################################################\n# There are a series of settings that this file controls in addtion to listing\n# particular directories to sweep. These are:\n#\n# dir_group - if the dir_group matches the section name.\n#\n# \n#\n#\n[ftp_internet]\n#\n#\n################################################################################\ndir_group=ftp_internet\n\n#\n# 5 failures in 60 minutes is something\n# to start getting worried about. We\n# need to allow for this timeframe because\n# a single transfer may go for quite a while before failing.\n\n#\nmax_failure_count=5\nmax_failure_minutes=60\n\n################################################################################\n#\n#\n[Crypt]\n#\n#\n################################################################################\ndir_group=Crypt\n#\n# 5 failures in 5 minutes\n# This would mean someone is continuously submitting\n# jobs and they fail quickly, which means there is \n# probably a core GPG or key problem.\n#\n#\nmax_failure_count=5\nmax_failure_minutes=5\n