Windows Scheduled Tasks

Anyone have any suggestions for scheduled tasks cookbooks that work well
with both 2003 and 2008 Windows Server?

  • Nikhil Shah */ System Administrator

nshah@theorchard.com

The Orchard® / www.theorchard.com

t (+1) 212.308.5648 / f (+1) 212.201.9203
23 E. 4th St., 3rd Fl / New York, NY 10003

The Daily Rind™ / www.dailyrindblog.com http://www.dailyrindblog.com/

Facebook http://www.facebook.com/theorchard /
@orchtweetshttp://www.twitter.com/orchtweets

Privileged And Confidential Communication.

This electronic transmission, and any documents attached hereto, (a) are
protected by the Electronic Communications Privacy Act (18 USC §§
2510-2521), (b) may contain confidential and/or legally privileged
information, and © are for the sole use of the intended recipient named
above. If you have received this electronic message in error, please notify
the sender and delete the electronic message. Any disclosure, copying,
distribution, or use of the contents of the information received in error
is strictly prohibited

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:nshah@theorchard.com]
Sent: Wednesday, January 15, 2014 11:49 AM
To: chef@lists.opscode.com
Subject: [chef] Windows Scheduled Tasks

Anyone have any suggestions for scheduled tasks cookbooks that work well with both 2003 and 2008 Windows Server?


Nikhil Shah / System Administrator

nshah@theorchard.comhttp://theorchard.com

The Orchard® / www.theorchard.comhttp://www.theorchard.com

t (+1) 212.308.5648 / f (+1) 212.201.9203
23 E. 4th St., 3rd Fl / New York, NY 10003

The Daily Rind™ / www.dailyrindblog.comhttp://www.dailyrindblog.com/

Facebookhttp://www.facebook.com/theorchard / @orchtweetshttp://www.twitter.com/orchtweets

Privileged And Confidential Communication.

This electronic transmission, and any documents attached hereto, (a) are protected by the Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain confidential and/or legally privileged information, and © are for the sole use of the intended recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of the information received in error is strictly prohibited

Does the windows_task custom resource in the windows cookbook not work?

  • Julian

On Wed, Jan 15, 2014 at 3:32 PM, Adam Barrand
adam.barrand@alliedpayment.com wrote:

I had to write my own lwrp.

From: Nikhil Shah [mailto:nshah@theorchard.com]
Sent: Wednesday, January 15, 2014 11:49 AM
To: chef@lists.opscode.com
Subject: [chef] Windows Scheduled Tasks

Anyone have any suggestions for scheduled tasks cookbooks that work well
with both 2003 and 2008 Windows Server?

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]