clean up how it puts the files in place - in f18 /tmp is tmpfs which
means ln and os.rename() won't work across fs.
This commit is contained in:
parent
7238fcb522
commit
9355f6e545
1 changed files with 12 additions and 3 deletions
15
cron
15
cron
|
@ -132,6 +132,7 @@ updates: Mike Grozak
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import os
|
||||||
|
|
||||||
def get_jobs_file(module, user, tmpfile, cron_file):
|
def get_jobs_file(module, user, tmpfile, cron_file):
|
||||||
if cron_file:
|
if cron_file:
|
||||||
|
@ -143,11 +144,19 @@ def get_jobs_file(module, user, tmpfile, cron_file):
|
||||||
|
|
||||||
def install_jobs(module, user, tmpfile, cron_file):
|
def install_jobs(module, user, tmpfile, cron_file):
|
||||||
if cron_file:
|
if cron_file:
|
||||||
cmd = "ln -f %s /etc/cron.d/%s" % (tmpfile, cron_file)
|
cron_file = '/etc/cron.d/%s' % cron_file
|
||||||
|
try:
|
||||||
|
module.atomic_replace(tmpfile, cron_file)
|
||||||
|
except (OSError, IOError), e:
|
||||||
|
return (1, "", str(e))
|
||||||
|
except:
|
||||||
|
return (1, "", str(e))
|
||||||
|
else:
|
||||||
|
return (0, "", "")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
cmd = "crontab %s %s" % (user, tmpfile)
|
cmd = "crontab %s %s" % (user, tmpfile)
|
||||||
|
return module.run_command(cmd)
|
||||||
return module.run_command(cmd)
|
|
||||||
|
|
||||||
def get_jobs(tmpfile):
|
def get_jobs(tmpfile):
|
||||||
lines = open(tmpfile).read().splitlines()
|
lines = open(tmpfile).read().splitlines()
|
||||||
|
|
Loading…
Reference in a new issue