-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A hook that randomizes the system crontab
- Loading branch information
1 parent
6a1f59b
commit 60f598b
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2011 Greek Research and Technology Network | ||
# | ||
|
||
set -e | ||
|
||
. common.sh | ||
|
||
debug set -x | ||
|
||
trap cleanup EXIT | ||
|
||
n=$RANDOM | ||
min=$(( n %= 30 )) | ||
|
||
echo "SHELL=/bin/sh" > ${TARGET}/etc/crontab | ||
echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> ${TARGET}/etc/crontab | ||
printf "\n" >> ${TARGET}/etc/crontab | ||
echo "# m h dom mon dow user command" >> ${TARGET}/etc/crontab | ||
echo "$min * * * * root cd / && run-parts --report cron.hourly" >> ${TARGET}/etc/crontab | ||
echo "$((min + 7)) 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report cron.daily )" >> ${TARGET}/etc/crontab | ||
echo "$((min + 13)) 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report cron.weekly )" >> ${TARGET}/etc/crontab | ||
echo "$((min + 24)) 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report cron.monthly )" >> ${TARGET}/etc/crontab | ||
|
||
trap - EXIT | ||
exit 0 |