-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrontab-env.sh
executable file
·47 lines (37 loc) · 1.03 KB
/
crontab-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
#------------------------------------------------
# require: crontab
# target : generate crontab script
# author : [email protected]
#------------------------------------------------
DEP="${DEP:-$(cd `dirname ${BASH_SOURCE[0]}`; pwd -P)}"
RUN="${RUN:-${DEP%/}/run}"
CRONTAB_LIST="crontab.list"
VER="${VER:-8.5.16}"
if [ -f "${CRONTAB_LIST}" ]; then
mv "${CRONTAB_LIST}" "${CRONTAB_LIST}.pre"
fi
cat << END > "${DEP%/}/${CRONTAB_LIST}"
# generated by crontab-env.sh
# @"https://raw.githubusercontent.com/junjiemars/kit/master/ul/crontab-env.sh"
SHELL=`which bash`
PATH=${DEP%/}${PATH:+:$PATH}
RUN=${RUN%/}
VER=$VER
# crontab list
# *minute(0-59) *hour(0-23) *day-of-month(1-31) *month(1-12) *day-of-week(0-7)
# contab examples:
# every 5 minutes : */5 * * * * <job>
# 5th weekday : * * * * 5 <job>
# 1st or 15th hour : * 1,15 * * * <job>
# TODO:
# * * * * * <job> >> /tmp/x.log 2>&1
#------------------
# existing jobs ...
#------------------
`
if $(hash crontab &>/dev/null); then
crontab -l 2>/dev/null
fi
`
END