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.

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!

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 Schroeder wrote:

<http://en.wikipedia.org/wiki/Man_page&gt;

HTH,

Preksha Patel wrote:

Hassan Schroeder 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&gt;

HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com 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 Patel wrote:

Hassan Schroeder 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&gt;

HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com twitter: @hassan      hi,

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.

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

Bingo :slight_smile:

Preksha Patel wrote:

Preksha Patel wrote:

Hassan Schroeder 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&gt;

HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com 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??

No, I gave you a trivial example of a running a simple Ruby program via script/runner. You should write your program to do whatever you want.

As far as knowing if it's working via cron -- the man pages explain all that.

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

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.