1
0
Fork 0
mirror of https://github.com/yavook/kiwi-cron.git synced 2024-11-21 15:03:01 +00:00

little refactorings

This commit is contained in:
Jörn-Michael Miehe 2022-03-02 18:55:29 +01:00
parent 351c46fe66
commit 038aecad4c
2 changed files with 5 additions and 17 deletions

View file

@ -4,7 +4,7 @@ cs_every="${1:-1}"
cs_units="${2}"
cs_command="${3}"
if [ "${cs_every}" -eq 1 ]; then
if [ "${cs_every}" = "1" ]; then
cs_every=""
else
cs_every="/${cs_every}"

View file

@ -1,28 +1,16 @@
#!/bin/sh
print_cron_schedule () {
pcs_minute="${1}"
pcs_hour="${2}"
pcs_day="${3}"
pcs_month="${4}"
pcs_weekday="${5}"
pcs_command="${6}"
printf '%-8s%-8s%-8s%-8s%-8s%s\n' \
"${pcs_minute}" "${pcs_hour}" "${pcs_day}" "${pcs_month}" "${pcs_weekday}" "${pcs_command}"
}
# header
echo '# crontab generated by kiwi-cron'
echo '# generation time: '"$(date)"
echo '#'
# short documentation line
print_cron_schedule \
printf '%-8s%-8s%-8s%-8s%-8s%s\n' \
"# min" "hour" "day" "month" "weekday" "command"
# schedules
while read -r pc_min pc_hour pc_day pc_month pc_weekday pc_command; do
print_cron_schedule \
"${pc_min}" "${pc_hour}" "${pc_day}" "${pc_month}" "${pc_weekday}" "${pc_command}"
while read -r pc_minute pc_hour pc_day pc_month pc_weekday pc_command; do
printf '%-8s%-8s%-8s%-8s%-8s%s\n' \
"${pc_minute}" "${pc_hour}" "${pc_day}" "${pc_month}" "${pc_weekday}" "${pc_command}"
done