You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.4 KiB

from ee.core.shellexec import EEShellExec
9 years ago
from ee.core.logging import Log
"""
Set CRON on LINUX system.
"""
class EECron():
def setcron_weekly(self,cmd,comment='Cron set by EasyEngine',user='root',min=0,hour=12):
9 years ago
if not EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
"2> /dev/null | {{ cat; echo -e"
" \\\""
"\\n0 0 * * 0 "
"{0}".format(cmd) +
" # {0}".format(comment)+
9 years ago
"\\\"; } | crontab -\"")
Log.debug(self, "Cron set")
9 years ago
def remove_cron(self,cmd):
if EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab "
"-l | sed '/{0}/d'"
"| crontab -\""
.format(cmd)):
9 years ago
Log.error(self, "Failed to remove crontab entry",False)
else:
Log.debug(self, "Cron not found")