Skip to content

Commit 85ed099

Browse files
committed
bug fix: cron
1 parent be9a761 commit 85ed099

2 files changed

Lines changed: 34 additions & 24 deletions

File tree

install/install.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,22 +1679,28 @@ def setup_cron(self):
16791679

16801680
##
16811681

1682-
cronFile = open("/var/spool/cron/root", "a")
1683-
cronFile.writelines("0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1" + "\n")
1684-
cronFile.writelines("0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py hourlyCleanup >/dev/null 2>&1" + "\n")
1685-
cronFile.writelines("0 0 1 * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py monthlyCleanup >/dev/null 2>&1" + "\n")
1686-
cronFile.writelines("0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/upgradeCritical.py >/dev/null 2>&1" + "\n")
1687-
cronFile.writelines("0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py >/dev/null 2>&1" + "\n")
1688-
cronFile.close()
1682+
CentOSPath = '/etc/redhat-release'
16891683

1690-
command = 'chmod +x /usr/local/CyberCP/plogical/findBWUsage.py'
1691-
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
1684+
if os.path.exists(CentOSPath):
1685+
cronPath = '/var/spool/cron/root'
1686+
else:
1687+
cronPath = '/var/spool/cron/crontabs/root'
16921688

1693-
command = 'chmod +x /usr/local/CyberCP/plogical/upgradeCritical.py'
1694-
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
1689+
cronFile = open(cronPath, "w")
16951690

1696-
command = 'chmod +x /usr/local/CyberCP/postfixSenderPolicy/client.py'
1697-
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
1691+
1692+
content = """
1693+
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1
1694+
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py hourlyCleanup >/dev/null 2>&1
1695+
0 0 1 * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py monthlyCleanup >/dev/null 2>&1
1696+
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/upgradeCritical.py >/dev/null 2>&1
1697+
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py >/dev/null 2>&1
1698+
7 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
1699+
0 12 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily
1700+
0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP
1701+
"""
1702+
cronFile.write(content)
1703+
cronFile.close()
16981704

16991705
if self.distro == centos or self.distro == cent8:
17001706
command = 'systemctl restart crond.service'
@@ -2131,15 +2137,6 @@ def installRestic(self):
21312137

21322138
data = open(cronTab, 'r').read()
21332139

2134-
if data.find('IncScheduler') == -1:
2135-
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
2136-
2137-
writeToFile = open(cronTab, 'a')
2138-
writeToFile.writelines(cronJob)
2139-
2140-
cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Weekly\n'
2141-
writeToFile.writelines(cronJob)
2142-
writeToFile.close()
21432140
except:
21442141
pass
21452142

plogical/upgrade.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,8 @@ def runSomeImportantBash():
20652065
data = open(cronPath, 'r').read()
20662066

20672067
if data.find('findBWUsage') == -1:
2068-
content = """0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1
2068+
content = """
2069+
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1
20692070
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py hourlyCleanup >/dev/null 2>&1
20702071
0 0 1 * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py monthlyCleanup >/dev/null 2>&1
20712072
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/upgradeCritical.py >/dev/null 2>&1
@@ -2076,13 +2077,25 @@ def runSomeImportantBash():
20762077
writeToFile = open(cronPath, 'w')
20772078
writeToFile.write(content)
20782079
writeToFile.close()
2080+
2081+
if data.find('IncScheduler.py') == -1:
2082+
content = """
2083+
0 12 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily
2084+
0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Weekly
2085+
"""
2086+
writeToFile = open(cronPath, 'w')
2087+
writeToFile.write(content)
2088+
writeToFile.close()
20792089
else:
2080-
content = """0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1
2090+
content = """
2091+
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/findBWUsage.py >/dev/null 2>&1
20812092
0 * * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py hourlyCleanup >/dev/null 2>&1
20822093
0 0 1 * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/postfixSenderPolicy/client.py monthlyCleanup >/dev/null 2>&1
20832094
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/upgradeCritical.py >/dev/null 2>&1
20842095
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py >/dev/null 2>&1
20852096
7 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
2097+
0 12 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily
2098+
0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Weekly
20862099
"""
20872100
writeToFile = open(cronPath, 'w')
20882101
writeToFile.write(content)

0 commit comments

Comments
 (0)