Cron


#1

I am trying to use the cron cookbook. I am unsure how to specify a file to
upload to the server and to run that script within the cron job.

  • 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


#2

You would use a cookbook_file resource for that (or template, or
remote_file). The cron resource only handles the cron scheduling side of
things.


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Wed, Sep 4, 2013 at 11:49 AM, Nikhil Shah nshah@theorchard.com wrote:

I am trying to use the cron cookbook. I am unsure how to specify a file to
upload to the server and to run that script within the cron job.

  • 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


#3

I am not sure what you mean by that. Do I have to use another cookbook? Would you be able to provide an example?
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 © 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.

On Sep 4, 2013, at 2:54 PM, Morgan Blackthorne stormerider@gmail.com wrote:

You would use a cookbook_file resource for that (or template, or remote_file). The cron resource only handles the cron scheduling side of things.


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Wed, Sep 4, 2013 at 11:49 AM, Nikhil Shah nshah@theorchard.com wrote:
I am trying to use the cron cookbook. I am unsure how to specify a file to upload to the server and to run that script within the cron job.


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 © 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


#4

cookbook_file is a native Chef resource:
http://docs.opscode.com/resource_cookbook_file.html


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Wed, Sep 4, 2013 at 11:57 AM, Nikhil Shah nshah@theorchard.com wrote:

I am not sure what you mean by that. Do I have to use another cookbook?
Would you be able to provide an example?
*Nikhil Shah */ System Administrator
nshah@theorchard.com drudolph@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.
*

On Sep 4, 2013, at 2:54 PM, Morgan Blackthorne stormerider@gmail.com
wrote:

You would use a cookbook_file resource for that (or template, or
remote_file). The cron resource only handles the cron scheduling side of
things.


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Wed, Sep 4, 2013 at 11:49 AM, Nikhil Shah nshah@theorchard.com wrote:

I am trying to use the cron cookbook. I am unsure how to specify a file
to upload to the server and to run that script within the cron job.

  • Nikhil Shah */ System Administrator

nshah@theorchard.com http://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


#5

A more complete example, using the cron cookbook 1:

my_cookbook/recipes/somecron.rb:

include_recipe ‘cron’

cookbook_file ‘/tmp/my_special_script.sh’ do
mode 00755
end

cron_d ‘run_my_special_script’ do
minute 0
hour 22
command "/tmp/my_special_script.sh"
user "appuser"
end

You could also deploy a straight cron file into /etc/cron.d/, but
I prefer the cron cookbook and the resource it provides.

-M

On Wed, Sep 4, 2013 at 3:01 PM, Morgan Blackthorne stormerider@gmail.comwrote:

cookbook_file is a native Chef resource:
http://docs.opscode.com/resource_cookbook_file.html


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Wed, Sep 4, 2013 at 11:57 AM, Nikhil Shah nshah@theorchard.com wrote:

I am not sure what you mean by that. Do I have to use another cookbook?
Would you be able to provide an example?
*Nikhil Shah */ System Administrator
nshah@theorchard.com drudolph@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.
*

On Sep 4, 2013, at 2:54 PM, Morgan Blackthorne stormerider@gmail.com
wrote:

You would use a cookbook_file resource for that (or template, or
remote_file). The cron resource only handles the cron scheduling side of
things.


~~ StormeRider ~~

“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… http://bit.ly/Ps3uSS

On Wed, Sep 4, 2013 at 11:49 AM, Nikhil Shah nshah@theorchard.comwrote:

I am trying to use the cron cookbook. I am unsure how to specify a file
to upload to the server and to run that script within the cron job.

  • Nikhil Shah */ System Administrator

nshah@theorchard.com http://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.comhttp://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


#6

Is the below section actually taking the script from your /tmp folder and uploading it to the server in the /tmp directory?

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 © 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.

On Sep 4, 2013, at 3:13 PM, Mike miketheman@gmail.com wrote:

cookbook_file ‘/tmp/my_special_script.sh’ do
mode 00755
end


#7

Nope, as Morgan pointed out, look at the behavior of the cookbook_file
resource and understand where the resource will look for the file (within
the files/ subdir in your cookbook).
-M

On Wed, Sep 4, 2013 at 3:20 PM, Nikhil Shah nshah@theorchard.com wrote:

Is the below section actually taking the script from your /tmp folder and
uploading it to the server in the /tmp directory?

*Nikhil Shah */ System Administrator
nshah@theorchard.com drudolph@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.
*

On Sep 4, 2013, at 3:13 PM, Mike miketheman@gmail.com wrote:

cookbook_file ‘/tmp/my_special_script.sh’ do
mode 00755
end


#8

ah yes…I was a bit confused b/c most of the cookbooks already has files/defaults… I was able to get this deployed. Thanks for you help guys!

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 © 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.

On Sep 4, 2013, at 3:24 PM, Mike miketheman@gmail.com wrote:

Nope, as Morgan pointed out, look at the behavior of the cookbook_file resource and understand where the resource will look for the file (within the files/ subdir in your cookbook).
-M

On Wed, Sep 4, 2013 at 3:20 PM, Nikhil Shah nshah@theorchard.com wrote:
Is the below section actually taking the script from your /tmp folder and uploading it to the server in the /tmp directory?

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 © 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.

On Sep 4, 2013, at 3:13 PM, Mike miketheman@gmail.com wrote:

cookbook_file ‘/tmp/my_special_script.sh’ do
mode 00755
end


#9

One last question re: the cron cookbook. How do you get it to run every 5 minutes?

cron_d ‘plugin_script’ do
minute 5
hour
command "/root/plugin.sh"
user “root”

^^ Would run every hour at 1:05, 2:05

cron_d ‘plugin_script’ do
minute /5
hour
command "/root/plugin.sh"
user “root”

^^ Doesn’t like the regex syntax

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 © 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.

On Sep 4, 2013, at 3:24 PM, Mike miketheman@gmail.com wrote:

Nope, as Morgan pointed out, look at the behavior of the cookbook_file resource and understand where the resource will look for the file (within the files/ subdir in your cookbook).
-M

On Wed, Sep 4, 2013 at 3:20 PM, Nikhil Shah nshah@theorchard.com wrote:
Is the below section actually taking the script from your /tmp folder and uploading it to the server in the /tmp directory?

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 © 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.

On Sep 4, 2013, at 3:13 PM, Mike miketheman@gmail.com wrote:

cookbook_file ‘/tmp/my_special_script.sh’ do
mode 00755
end


#10

disregard my last =)
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 © 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.

On Sep 4, 2013, at 3:48 PM, Nikhil Shah nshah@theorchard.com wrote:

One last question re: the cron cookbook. How do you get it to run every 5 minutes?

cron_d ‘plugin_script’ do
minute 5
hour
command "/root/plugin.sh"
user “root”

^^ Would run every hour at 1:05, 2:05

cron_d ‘plugin_script’ do
minute /5
hour
command "/root/plugin.sh"
user “root”

^^ Doesn’t like the regex syntax

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 © 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.

On Sep 4, 2013, at 3:24 PM, Mike miketheman@gmail.com wrote:

Nope, as Morgan pointed out, look at the behavior of the cookbook_file resource and understand where the resource will look for the file (within the files/ subdir in your cookbook).
-M

On Wed, Sep 4, 2013 at 3:20 PM, Nikhil Shah nshah@theorchard.com wrote:
Is the below section actually taking the script from your /tmp folder and uploading it to the server in the /tmp directory?

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 © 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.

On Sep 4, 2013, at 3:13 PM, Mike miketheman@gmail.com wrote:

cookbook_file ‘/tmp/my_special_script.sh’ do
mode 00755
end


#11

Try:

cron_d ‘plugin_script’ do
minute "/5"
command "/root/plugin.sh"
user "root"
end

On Wed, Sep 4, 2013 at 3:48 PM, Nikhil Shah nshah@theorchard.com wrote:

One last question re: the cron cookbook. How do you get it to run every 5
minutes?

cron_d ‘plugin_script’ do
minute 5
hour
command "/root/plugin.sh"
user “root”

^^ Would run every hour at 1:05, 2:05

cron_d ‘plugin_script’ do
minute /5
hour
command "/root/plugin.sh"
user “root”

^^ Doesn’t like the regex syntax

*Nikhil Shah */ System Administrator
nshah@theorchard.com drudolph@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.
*

On Sep 4, 2013, at 3:24 PM, Mike miketheman@gmail.com wrote:

Nope, as Morgan pointed out, look at the behavior of the cookbook_file
resource and understand where the resource will look for the file (within
the files/ subdir in your cookbook).
-M

On Wed, Sep 4, 2013 at 3:20 PM, Nikhil Shah nshah@theorchard.com wrote:

Is the below section actually taking the script from your /tmp folder and
uploading it to the server in the /tmp directory?

*Nikhil Shah */  System Administrator

nshah@theorchard.com drudolph@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.
*

On Sep 4, 2013, at 3:13 PM, Mike miketheman@gmail.com wrote:

cookbook_file ‘/tmp/my_special_script.sh’ do
mode 00755
end