forked from littlebizzy/slickstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ss-install-ubuntu-crontab.txt
57 lines (44 loc) · 2.95 KB
/
ss-install-ubuntu-crontab.txt
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
50
51
52
53
54
55
56
57
#!/bin/bash
####################################################################################################
#### author: SlickStack ############################################################################
#### link: https://slickstack.io ###################################################################
#### mirror: http://mirrors.slickstack.io/ss-install-ubuntu-crontab.txt ############################
#### path: /var/www/ss-install-ubuntu-crontab ######################################################
#### destination: n/a (not a boilerplate) ##########################################################
#### purpose: Reinstalls cron, the root Crontab, and SlickStack Core cron jobs (idempotent) ########
#### module version: Ubuntu 20.04 LTS ##############################################################
####################################################################################################
## SS-CONFIG MUST BE PROPERLY CONFIGURED (AND CURRENT BUILD) BEFORE RUNNING SS-INSTALL ##
## ENSURE SS-CONFIG OPTIONS REMAIN CURRENT BY RUNNING SS-UPDATE OCCASIONALLY ##
## include SlickStack configuration ##
source /var/www/ss-config
## include SlickStack functions ##
source /var/www/ss-functions
####################################################################################################
#### SS-Install-Ubuntu-Crontab: Ensure Cron Installed + Install SlickStack (Root) Crontab ##########
####################################################################################################
## ensure cron package installed (default on Ubuntu) ##
apt install cron
## delete tmp files ##
rm /tmp/*crontab*
# install crontab (unique to SlickStack) ##
cp /var/www/00-crontab /tmp/00-crontab
sed -i "s/@RANDOM_STRING/$(openssl rand -hex 12)/g" /tmp/00-crontab
sudo crontab /tmp/00-crontab
## reset permissions ##
chown root:root /var/spool/cron/crontabs/root ## must be root:root
chmod 0600 /var/spool/cron/crontabs/root ## must be exactly 0600 or crontab will fail
## restart services ##
/etc/init.d/cron reload ## reload better than restart
####################################################################################################
#### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ###############
####################################################################################################
## Ref: https://linuxize.com/post/bash-functions/
## Ref: https://www.cyberciti.biz/faq/unix-linux-appleosx-bsd-shell-appending-date-to-filename/
## Ref: https://wordpress.stackexchange.com/questions/199725/triggering-cron-by-calling-wp-cron-php-on-the-command-line-rather-than-with-wget
## Ref: https://help.ubuntu.com/community/CronHowto
## Ref: https://www.rosehosting.com/blog/ubuntu-crontab/
## Ref: https://linuxize.com/post/scheduling-cron-jobs-with-crontab/
## Ref: https://www.rosehosting.com/blog/ubuntu-crontab/
## Ref: https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-ubuntu-1804
## SS_EOF