Skip to content

Commit e57609d

Browse files
committed
only reload once, at the end. this speeds up multiple changes in a single run
1 parent 4fd7ce7 commit e57609d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crontroll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ main() {
167167
exit
168168
fi
169169
checkargs "$@"
170+
donesomething=false
171+
reload=false
170172
for f in "$@"; do
171173
if [ ! -f "$f" ]; then
172174
echo >&2 "$f not found"
@@ -181,12 +183,12 @@ main() {
181183
fi
182184
if [ "${command}" = "disable" ]; then
183185
donesomething=true
186+
reload=true
184187
printf "#%s\n" "$cronjob" > "$f"
185-
reload_crontab
186188
elif [ "${command}" = "enable" ]; then
187189
donesomething=true
190+
reload=true
188191
printf "%s\n" "$cronjob" > "$f"
189-
reload_crontab
190192
elif [ "${command}" = "now" ] || [ "${command}" = "now_force" ] || [ "${command}" = "now_wait" ]; then
191193
donesomething=true
192194
lock="$lockdir/$1.lock"
@@ -218,6 +220,9 @@ main() {
218220
printf "%s: %s; %s\n" "$status" "$f" "$cronjob"
219221
fi
220222
done
223+
if $reload;then
224+
reload_crontab
225+
fi
221226
if ! $donesomething; then
222227
checkargs "$command"
223228
echo >&2 "Unknown command: $command"

0 commit comments

Comments
 (0)