[chef] RE: Windows Scheduled Tasks


Chronological Thread 
  • From: Adam Barrand < >
  • To: " " < >
  • Subject: [chef] RE: Windows Scheduled Tasks
  • Date: Wed, 15 Jan 2014 20:32:03 +0000
  • Accept-language: en-US

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:
Sent: Wednesday, January 15, 2014 11:49 AM
To:
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.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

Facebook / @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 (c) 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




Archive powered by MHonArc 2.6.16.

§