reformat code
This commit is contained in:
@@ -5,28 +5,27 @@ from wo.core.logging import Log
|
||||
Set CRON on LINUX system.
|
||||
"""
|
||||
|
||||
|
||||
class WOCron():
|
||||
def setcron_weekly(self,cmd,comment='Cron set by WordOps',user='root',min=0,hour=12):
|
||||
def setcron_weekly(self, cmd, comment='Cron set by WordOps', user='root', min=0, hour=12):
|
||||
if not WOShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
|
||||
|
||||
WOShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
|
||||
"2> /dev/null | {{ cat; echo -e"
|
||||
" \\\""
|
||||
"\\n0 0 * * 0 "
|
||||
"{0}".format(cmd) +
|
||||
" # {0}".format(comment)+
|
||||
"\\\"; } | crontab -\"")
|
||||
"2> /dev/null | {{ cat; echo -e"
|
||||
" \\\""
|
||||
"\\n0 0 * * 0 "
|
||||
"{0}".format(cmd) +
|
||||
" # {0}".format(comment) +
|
||||
"\\\"; } | crontab -\"")
|
||||
Log.debug(self, "Cron set")
|
||||
|
||||
|
||||
|
||||
def remove_cron(self,cmd):
|
||||
def remove_cron(self, cmd):
|
||||
if WOShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
|
||||
if not WOShellExec.cmd_exec(self, "/bin/bash -c "
|
||||
"\"crontab "
|
||||
"-l | sed '/{0}/d'"
|
||||
"| crontab -\""
|
||||
.format(cmd)):
|
||||
Log.error(self, "Failed to remove crontab entry",False)
|
||||
"\"crontab "
|
||||
"-l | sed '/{0}/d'"
|
||||
"| crontab -\""
|
||||
.format(cmd)):
|
||||
Log.error(self, "Failed to remove crontab entry", False)
|
||||
else:
|
||||
Log.debug(self, "Cron not found")
|
||||
|
||||
Reference in New Issue
Block a user