Merge remote-tracking branch 'steven/__cron-special'
This commit is contained in:
commit
ffcb42ebc5
3 changed files with 26 additions and 35 deletions
|
@ -35,14 +35,25 @@ month::
|
||||||
See crontab(5). Defaults to *
|
See crontab(5). Defaults to *
|
||||||
day_of_week::
|
day_of_week::
|
||||||
See crontab(5). Defaults to *
|
See crontab(5). Defaults to *
|
||||||
|
raw::
|
||||||
|
Take whatever the user has given instead of time and date fields.
|
||||||
|
If given, all other time and date fields are ignored.
|
||||||
|
Can for example be used to specify cron EXTENSIONS like reboot, yearly etc.
|
||||||
|
See crontab(5) for the extensions if any that your cron implementation
|
||||||
|
implements.
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# add cronjob
|
# run Monday to Saturday at 23:15
|
||||||
__cron some-id --user root --command "/path/to/script"
|
__cron some-id --user root --command "/path/to/script" \
|
||||||
|
--hour 23 --minute 15 --day_of_week 1-6
|
||||||
|
|
||||||
|
# run on reboot
|
||||||
|
__cron some-id --user root --command "/path/to/script" \
|
||||||
|
--raw @reboot
|
||||||
|
|
||||||
# remove cronjob
|
# remove cronjob
|
||||||
__cron some-id --user root --command "/path/to/script" --state absent
|
__cron some-id --user root --command "/path/to/script" --state absent
|
||||||
|
|
|
@ -23,44 +23,23 @@ user="$(cat "$__object/parameter/user")"
|
||||||
command="$(cat "$__object/parameter/command")"
|
command="$(cat "$__object/parameter/command")"
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
if [ ! -f "$__object/parameter/state" ]; then
|
test -f "$__object/parameter/state" || echo "present" > "$__object/parameter/state"
|
||||||
echo "present" > "$__object/parameter/state"
|
|
||||||
fi
|
if [ -f "$__object/parameter/raw" ]; then
|
||||||
if [ -f "$__object/parameter/minute" ]; then
|
raw="$(cat "$__object/parameter/raw")"
|
||||||
minute="$(cat "$__object/parameter/minute")"
|
entry="$raw $command"
|
||||||
else
|
else
|
||||||
minute="*"
|
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
|
||||||
echo "$minute" > "$__object/parameter/minute"
|
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
|
||||||
fi
|
day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")"
|
||||||
if [ -f "$__object/parameter/hour" ]; then
|
month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")"
|
||||||
hour="$(cat "$__object/parameter/hour")"
|
day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")"
|
||||||
else
|
entry="$minute $hour $day_of_month $month $day_of_week $command"
|
||||||
hour="*"
|
|
||||||
echo "$hour" > "$__object/parameter/hour"
|
|
||||||
fi
|
|
||||||
if [ -f "$__object/parameter/day_of_month" ]; then
|
|
||||||
day_of_month="$(cat "$__object/parameter/day_of_month")"
|
|
||||||
else
|
|
||||||
day_of_month="*"
|
|
||||||
echo "$day_of_month" > "$__object/parameter/day_of_month"
|
|
||||||
fi
|
|
||||||
if [ -f "$__object/parameter/month" ]; then
|
|
||||||
month="$(cat "$__object/parameter/month")"
|
|
||||||
else
|
|
||||||
month="*"
|
|
||||||
echo "$month" > "$__object/parameter/month"
|
|
||||||
fi
|
|
||||||
if [ -f "$__object/parameter/day_of_week" ]; then
|
|
||||||
day_of_week="$(cat "$__object/parameter/day_of_week")"
|
|
||||||
else
|
|
||||||
day_of_week="*"
|
|
||||||
echo "$day_of_week" > "$__object/parameter/day_of_week"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# NOTE: if changed, also change in explorers
|
# NOTE: if changed, also change in explorers
|
||||||
prefix="#cdist:__cron/$name"
|
prefix="#cdist:__cron/$name"
|
||||||
suffix="#/cdist:__cron/$name"
|
suffix="#/cdist:__cron/$name"
|
||||||
echo "$prefix" | tee "$__object/parameter/prefix" > "$__object/parameter/entry"
|
echo "$prefix" | tee "$__object/parameter/prefix" > "$__object/parameter/entry"
|
||||||
echo "$minute $hour $day_of_month $month $day_of_week $command" >> "$__object/parameter/entry"
|
echo "$entry" >> "$__object/parameter/entry"
|
||||||
echo "$suffix" | tee "$__object/parameter/suffix" >> "$__object/parameter/entry"
|
echo "$suffix" | tee "$__object/parameter/suffix" >> "$__object/parameter/entry"
|
||||||
|
|
||||||
|
|
|
@ -4,3 +4,4 @@ hour
|
||||||
day_of_month
|
day_of_month
|
||||||
month
|
month
|
||||||
day_of_week
|
day_of_week
|
||||||
|
raw
|
||||||
|
|
Loading…
Reference in a new issue