For crontab

hi all,

i haven’t used cron yet but now i want to use it and got some idea
about cron from google but not exactly…
so i want to use cron in ruby on rails application. in application i
want to fire some query everyday so where i should write the code for
query so that when cron is run that query is also fire??

can any one please help me??

thanks,
Preksha.

On Sat, Sep 19, 2009 at 12:33 AM, Preksha P.
[email protected] wrote:

so i want to use cron in ruby on rails application. in application i
want to fire some query everyday so where i should write the code for
query so that when cron is run that query is also fire??

Cron runs whatever you tell it too, wherever that is. :slight_smile:

If you want to run something with the Rails app’s environment, you
probably want to add the code to {RAILS_ROOT}/lib and invoke it
via {RAILS_ROOT}/script/runner

HTH!

Hassan S. ------------------------ [email protected]
twitter: @hassan

Hassan S. wrote:

On Sat, Sep 19, 2009 at 12:33 AM, Preksha P.
[email protected] wrote:

so i want to use cron in ruby on rails application. in application i
want to fire some query everyday so where i should write the code for
query so that when cron is run that query is also fire??

Cron runs whatever you tell it too, wherever that is. :slight_smile:

If you want to run something with the Rails app’s environment, you
probably want to add the code to {RAILS_ROOT}/lib and invoke it
via {RAILS_ROOT}/script/runner

HTH!

Hassan S. ------------------------ [email protected]
twitter: @hassan

hi,
as you told to add the code to {RAILS_ROOT}/lib so you mean to say to
add the code in lib folder, i have to make one file with extension is
what?? and {RAILS_ROOT}/script/runner is the command which i should
run??
i haven’t used corn before so can you please tell me something in
detail??

thanks,
Preksha…

Hi Preksha
Read this

http://railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial

Sijo

Hassan S. wrote:

On Sun, Sep 20, 2009 at 8:56 PM, Preksha P.
[email protected] wrote:

as you told to add the code to {RAILS_ROOT}/lib so you mean to say to
add the code in lib folder, i have to make one file with extension is
what?? and {RAILS_ROOT}/script/runner is the command which i should
run??

~/projects/example$ more lib/whatever.rb
class Whatever
class << self
def say_it
puts “it, that’s all”
end
end
end
~/projects/example$ script/runner Whatever.say_it
it, that’s all
~/projects/example$

i haven’t used corn before so can you please tell me something in
detail??

Have you read the man pages for cron and crontab? That should be
enough examples to get you started, I’d think. :slight_smile:


Hassan S. ------------------------ [email protected]
twitter: @hassan

hi,

i haven’t read man pages for cron or crontab…can you please help me
for that??i mean from where i can read it?? can you please give me
link??

thanks,
Preksha…

On Sun, Sep 20, 2009 at 8:56 PM, Preksha P.
[email protected] wrote:

as you told to add the code to {RAILS_ROOT}/lib so you mean to say to
add the code in lib folder, i have to make one file with extension is
what?? and {RAILS_ROOT}/script/runner is the command which i should
run??

~/projects/example$ more lib/whatever.rb
class Whatever
class << self
def say_it
puts “it, that’s all”
end
end
end
~/projects/example$ script/runner Whatever.say_it
it, that’s all
~/projects/example$

i haven’t used corn before so can you please tell me something in
detail??

Have you read the man pages for cron and crontab? That should be
enough examples to get you started, I’d think. :slight_smile:


Hassan S. ------------------------ [email protected]
twitter: @hassan

Hi

.but is it for cron or crontab?

Did not get what you meant by this question. Anyway

cron is a unix, solaris utility that allows tasks to be automatically
run in the background at regular intervals by the cron daemon
And
Crontab (CRON Table) is a file which contains the schedule of cron
entries to be run and at specified times.

After creating your rake tasks you can call it fron cron For that from
console type
crontab -e
This will open the crontab file in edit mode There put your entries
ne example from above link is

0 0 * * * cd /var/www/apps/rails_app/ && /usr/local/bin/rake
RAILS_ENV=production utils:send_expire_soon_emails

Sijo

Sijo Kg wrote:

Hi Preksha
Read this

http://railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial

Sijo

hi,

thanks for giving this link…but is it for cron or crontab?

thanks,
Preksha…

Sijo Kg wrote:

Hi

.but is it for cron or crontab?

Did not get what you meant by this question. Anyway

cron is a unix, solaris utility that allows tasks to be automatically
run in the background at regular intervals by the cron daemon
And
Crontab (CRON Table) is a file which contains the schedule of cron
entries to be run and at specified times.

After creating your rake tasks you can call it fron cron For that from
console type
crontab -e
This will open the crontab file in edit mode There put your entries
ne example from above link is

0 0 * * * cd /var/www/apps/rails_app/ && /usr/local/bin/rake
RAILS_ENV=production utils:send_expire_soon_emails

hi,

but what’s this??
0 0 * * * cd /var/www/apps/rails_app/ && /usr/local/bin/rake
RAILS_ENV=production utils:send_expire_soon_emails

thanks,
Preksha…

Sijo

Preksha

but what’s this??
0 0 * * * cd /var/www/apps/rails_app/ && /usr/local/bin/rake
RAILS_ENV=production utils:send_expire_soon_emails

 This is how we setup cron entries. In this case what it means is 

Every midnight (12 am) go to the project root and run the rake task in
production mode The task is send_expire_soon_emails under namespace
utils

Another cron example entry
5,10 0 10 * 1 rm /tmp/*

this means At 12.05,12.10 every Monday & on 10th of every month 

clear tmp directory.

Sijo

Hassan S. wrote:

On Sun, Sep 20, 2009 at 11:27 PM, Preksha P.
[email protected] wrote:

i haven’t read man pages for cron or crontab…can you please help me
for that??i mean from where i can read it?? can you please give me
link??

http://en.wikipedia.org/wiki/Man_page

HTH,

Hassan S. ------------------------ [email protected]
twitter: @hassan

hi,

why you have given me this link??it is about man command for UNIX…

On Sun, Sep 20, 2009 at 11:27 PM, Preksha P.
[email protected] wrote:

i haven’t read man pages for cron or crontab…can you please help me
for that??i mean from where i can read it?? can you please give me
link??

http://en.wikipedia.org/wiki/Man_page

HTH,

Hassan S. ------------------------ [email protected]
twitter: @hassan

Preksha P. wrote:

Preksha P. wrote:

Hassan S. wrote:

On Sun, Sep 20, 2009 at 11:27 PM, Preksha P.
[email protected] wrote:

i haven’t read man pages for cron or crontab…can you please help me
for that??i mean from where i can read it?? can you please give me
link??

http://en.wikipedia.org/wiki/Man_page

HTH,

Hassan S. ------------------------ [email protected]
twitter: @hassan

hi,

why you have given me this link??it is about man command for UNIX…

hi,

Which things are necessary for cron and crontab…i mean what i suppose
to do for that??

hi,

one day you told me to follow using following code:
~/projects/example$ more lib/whatever.rb

class Whatever
class << self
def say_it
puts “it, that’s all”
end
end
end
~/projects/example$ script/runner Whatever.say_it
it, that’s all
~/projects/example$

i made this file and add this method but don’t i need to make a page for
say_it method?? how can i come to know that this cron is working i mean
where this message “it, that,s all” will display??

Preksha P. wrote:

Hassan S. wrote:

On Sun, Sep 20, 2009 at 11:27 PM, Preksha P.
[email protected] wrote:

i haven’t read man pages for cron or crontab…can you please help me
for that??i mean from where i can read it?? can you please give me
link??

http://en.wikipedia.org/wiki/Man_page

HTH,

Hassan S. ------------------------ [email protected]
twitter: @hassan

hi,

why you have given me this link??it is about man command for UNIX…

hi,

Which things are necessary for cron and crontab…i mean what i suppose
to do for that??

Preksha P. wrote:

http://en.wikipedia.org/wiki/Man_page

I imagine that he’s passed you that link so that you can learn how to
use man and then read the documentation for cron/ crontab.

Cheers,
Mohit.
9/22/2009 | 12:51 PM.

On Mon, Sep 21, 2009 at 9:51 PM, Mohit S. [email protected]
wrote:

why you have given me this link??it is about man command for UNIX…

I imagine that he’s passed you that link so that you can learn how to
use man and then read the documentation for cron/ crontab.

Bingo :slight_smile:


Hassan S. ------------------------ [email protected]
twitter: @hassan

Sijo Kg wrote:

Hi

.but is it for cron or crontab?

Did not get what you meant by this question. Anyway

cron is a unix, solaris utility that allows tasks to be automatically
run in the background at regular intervals by the cron daemon
And
Crontab (CRON Table) is a file which contains the schedule of cron
entries to be run and at specified times.

After creating your rake tasks you can call it fron cron For that from
console type
crontab -e
This will open the crontab file in edit mode There put your entries
ne example from above link is

0 0 * * * cd /var/www/apps/rails_app/ && /usr/local/bin/rake
RAILS_ENV=production utils:send_expire_soon_emails

hi,

where i supposed to write this:
0 0 * * * cd /var/www/apps/rails_app/ && /usr/local/bin/rake

RAILS_ENV=production utils:send_expire_soon_emails

i mean the code to fire an event at particular time tht where i supposed
to write?

Sijo

Hey,

Checkout ‘whenever’. Just used it for one of my projects. Worked
nicely, easily. All ruby, no fuss or weird cron job strings.

http://github.com/javan/whenever/blob/master/README.rdoc
http://wiki.github.com/javan/whenever/instructions-and-examples

Or if you do better with screencasts:

Hope this helps.

Regards
Kieran

On Sep 19, 7:33 pm, Preksha P. [email protected]

Preksha,

Did you take any effort to learn what cron is? Did you do Internet
search?
Anyway, I don’t think it’s anyway related to rails now, you need to read
man
pages for cron (available on Internet). And you will know what Kieran is
trying to tell if you click on those links and read.


Abhinav

On Wed, Sep 23, 2009 at 9:22 AM, Preksha P. <

Kieran P wrote:

Hey,

Checkout ‘whenever’. Just used it for one of my projects. Worked
nicely, easily. All ruby, no fuss or weird cron job strings.

GitHub - javan/whenever: Cron jobs in Ruby
http://github.com/javan/whenever/blob/master/README.rdoc
http://wiki.github.com/javan/whenever/instructions-and-examples

Or if you do better with screencasts:

#164 Cron in Ruby - RailsCasts

Hope this helps.

Regards
Kieran

On Sep 19, 7:33�pm, Preksha P. [email protected]
Hey,

what you are trying to tell me that i did not get you but will check
these links…if possible tell me what you were telling??