I had to write my own lwrp.
def
frequencyinterval(freq,
intrvl) value
=
1
intrvl
=
intrvl.to_i
case
freq
when
"MINUTE" (intrvl
>=
1
&&
intrvl
<=
1439)
?
value
=
intrvl : value
=
1
when
"HOURLY"
(intrvl
>=
1
&&
intrvl
<=
23)
?
value
=
intrvl : value
=
1
when
"DAILY" (intrvl
>=
1
&&
intrvl
<=
365)
?
value
=
intrvl : value
=
1
when
"MONTHLY" (intrvl
>=
1
&&
intrvl
<=
12)
?
value
=
intrvl : value
=
1
end
value end action
:create
do
puts
"Creating scheduled task #{new_resource.taskname}"
case
"#{new_resource.frequency}"
when
"ONSTART"
when
"LASTDAY" system("schtasks
/create /tn \"#{new_resource.taskname}\"
/tr \"#{new_resource.path} #{new_resource.arguments}\"
/sc #{new_resource.frequency} /RL HIGHEST
/RU SYSTEM /F")
else
interval
=
frequencyinterval("#{new_resource.frequency}",
"#{new_resource.interval}") system("schtasks
/create /tn \"#{new_resource.taskname}\"
/tr \"#{new_resource.path} #{new_resource.arguments}\"
/sc #{new_resource.frequency} /mo #{interval}
/RL HIGHEST /RU SYSTEM /F")
end
puts
"#{new_resource.taskname}
was created." end action
:delete
do
puts
"Deleting scheduled task #{new_resource.taskname}" system("schtasks
/delete /tn \"#{new_resource.taskname}\"
/f") puts
"Deleted task #{new_resource.taskname}" end action
:deleteall
do
puts
"Deleting all scheduled tasks" system("schtasks
/delete /tn * /f") puts
"All scheduled tasks deleted" end action
:modify
do
puts
"Modifying #{new_resource.taskname}" system("schtasks
/change /tn #{new_resource.taskname}
/tr #{new_resource.path} /RI")
puts
"Modified #{new_resource.taskname}" end From: Nikhil Shah [mailto:
Anyone have any suggestions for scheduled tasks cookbooks that work well with both 2003 and 2008 Windows Server?
-- Nikhil Shah
/ System Administrator The Daily Rind™ / www.dailyrindblog.com
|
Archive powered by MHonArc 2.6.16.