Created
June 4, 2019 03:57
-
-
Save smaeul/27bf469da1f7619e5f15a40cfade4996 to your computer and use it in GitHub Desktop.
execline-cron
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
#!/bin/execlineb -S2 | |
unexport CRON_SOCK | |
unexport CRON_TEMP | |
pipeline { | |
fdmove -c 2 1 | |
importas -u base CRON_BASE | |
unexport CRON_MAIL | |
foreground { ${base}/${1}/${2} } | |
importas -u exitval ? | |
if -t { test ${exitval} -gt 0 } | |
echo cron: ${2} exited with error ${exitval} | |
} | |
backtick -n tmpfile { s6-uniquename /tmp/ } | |
importas -u tmpfile tmpfile | |
seekablepipe ${tmpfile} | |
if -t { grep -q . /proc/self/fd/0 } | |
importas -u mail CRON_MAIL | |
if -t { test -n ${mail} } | |
mailx -s "cron: failure in ${1} job '${2}'" ${mail} |
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
#!/bin/execlineb -P | |
if { | |
backtick -n uid { id -u } | |
importas -u uid uid | |
if { mkdir -p rules/uid/${uid} } | |
touch rules/uid/${uid}/allow | |
} | |
importas -u sock CRON_SOCK | |
s6-ipcserver -1 ${sock} | |
s6-ipcserver-access -v 0 -E -i rules | |
s6-sudod -012 -t 1000 fdmove -c 1 2 cron-exec |
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
#!/bin/execlineb -P | |
importas XDG_CONFIG_HOME XDG_CONFIG_HOME | |
s6-envdir -fi ${XDG_CONFIG_HOME}/cron/env | |
cron-runner |
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
#!/bin/execlineb -P | |
multisubstitute { | |
importas -u base CRON_BASE | |
importas -u sock CRON_SOCK | |
importas -u temp CRON_TEMP | |
} | |
if { | |
forx group { hourly daily weekly monthly yearly } | |
importas -u group group | |
redirfd -w 2 /dev/null | |
cd ${base}/${group} | |
fdmove -c 2 1 | |
if { mkdir -p ${temp} } | |
if { | |
backtick -n period { | |
heredoc 0 ${group} | |
sed -e s/ly// -e s/dai/day/ | |
} | |
importas -u period period | |
backtick -n ref { date -d "1 ${period} ago" -u "+%Y-%m-%dT%H:59:59Z" } | |
importas -u ref ref | |
touch -d ${ref} ${temp}/reference | |
} | |
elglob -0 jobs * | |
forx job { ${jobs} } | |
importas -u job job | |
if { test -x ${job} } | |
if -nt { | |
backtick -n found { | |
redirfd -w 2 /dev/null | |
find ${temp}/${group}/${job} -prune -newer ${temp}/reference | |
} | |
importas -u found found | |
test -n ${found} | |
} | |
if { echo running job ${job} from group ${group} } | |
if { s6-sudo -e ${sock} ${group} ${job} } | |
if { mkdir -p ${temp}/${group} } | |
touch ${temp}/${group}/${job} | |
} | |
sleep 1800 |
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
#!/bin/execlineb -P | |
importas XDG_CONFIG_HOME XDG_CONFIG_HOME | |
s6-envdir -fi ${XDG_CONFIG_HOME}/cron/env | |
cron-scheduler |
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
.config/cron/env/CRON_BASE:/home/me/.config/cron | |
.config/cron/env/CRON_MAIL:[email protected] | |
.config/cron/env/CRON_SOCK:/run/user/me/cron | |
.config/cron/env/CRON_TEMP:/home/me/.cache/cron |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment