forked from DigiPlatMOOC/TelegramBotSample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-cronjob.sh
More file actions
49 lines (36 loc) · 824 Bytes
/
Copy pathsetup-cronjob.sh
File metadata and controls
49 lines (36 loc) · 824 Bytes
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
48
49
#!/bin/bash
#TODO: insert the full path of your php script (e.g. PHP_SCRIPT="/path/to/directory/hook.php")
PHP_SCRIPT="hook.php"
if [ -z "$PHP_SCRIPT" ]; then
echo "WARNING: Setup the actual PHP_SCRIPT path, please"
exit 0
fi
usage(){
echo "usage: $0 [ -r ] [ -h ] "
}
ACTION="SETUP"
while getopts rh option
do
case $option in
(r)
ACTION='remove';;
(h)
usage
exit;;
(*)
usage
exit;;
esac
done
if [ "$ACTION" = "SETUP" ]; then
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "* * * * * php $PHP_SCRIPT" >> mycron
else
#remove PHP_SCRIPT command
crontab -l | grep -v $PHP_SCRIPT > mycron
fi
#install new cron file
crontab mycron
rm mycron