Skip to content

Commit

Permalink
bug fix: cron path for ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Feb 11, 2020
1 parent d7b766c commit 0d54457
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions plogical/cronUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ def remCronbyLine(externalApp, line):
@staticmethod
def addNewCron(externalApp, finalCron):
try:
CronPath = '/var/spool/cron/%s' % (externalApp)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
cronPath = "/var/spool/cron/" + externalApp
else:
cronPath = "/var/spool/cron/crontabs/" + externalApp

with open(CronPath, "a") as file:
with open(cronPath, "a") as file:
file.write(finalCron + "\n")

print("1,None")
Expand Down
9 changes: 6 additions & 3 deletions websiteFunctions/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,11 +1548,14 @@ def addNewCron(self, userID=None, data=None):

website = Websites.objects.get(domain=self.domain)

CronPath = '/var/spool/cron/%s' % (website.externalApp)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
cronPath = "/var/spool/cron/" + website.externalApp
else:
cronPath = "/var/spool/cron/crontabs/" + website.externalApp

commandT = 'touch %s' % (CronPath)
commandT = 'touch %s' % (cronPath)
ProcessUtilities.executioner(commandT, 'root')
commandT = 'chown %s:%s %s' % (website.externalApp, website.externalApp, CronPath)
commandT = 'chown %s:%s %s' % (website.externalApp, website.externalApp, cronPath)
ProcessUtilities.executioner(commandT, 'root')

CronUtil.CronPrem(1)
Expand Down

0 comments on commit 0d54457

Please sign in to comment.