1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008-2013 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
5 local fs = require "nixio.fs"
6 local cronfile = "/etc/crontabs/root"
8 f = SimpleForm("crontab", translate("Scheduled Tasks"),
9 translate("This is the system crontab in which scheduled tasks can be defined.") ..
10 translate("<br/>Note: you need to manually restart the cron service if the " ..
11 "crontab file was empty before editing."))
13 t = f:field(TextValue, "crons")
17 return fs.readfile(cronfile) or ""
20 function f.handle(self, state, data)
21 if state == FORM_VALID then
23 fs.writefile(cronfile, data.crons:gsub("\r\n", "\n"))
24 luci.sys.call("/usr/bin/crontab %q" % cronfile)
26 fs.writefile(cronfile, "")