The cronjob question

27 views
Skip to first unread message

dongcan zhao

unread,
Apr 15, 2012, 11:56:48 PM4/15/12
to Rufus Ruby
the code is :
scheduler=Rufus::Scheduler::PlainScheduler.start_new
job=scheduler.cron '50 11 * * 1-5 Etc/GMT+8' do
puts "hello"
end
scheduler.join

I cannot find the output in the screen.So does it output into a file?
Or anything wrong with the code ?
I also want to know whether the "scheduler.join" is necessary in the
cron job? And this cronjob can be seen in the crontab?
Thanks !

John Mettraux

unread,
Apr 16, 2012, 12:23:13 AM4/16/12
to rufus...@googlegroups.com

On Sun, Apr 15, 2012 at 08:56:48PM -0700, dongcan zhao wrote:
> the code is :
> scheduler=Rufus::Scheduler::PlainScheduler.start_new
> job=scheduler.cron '50 11 * * 1-5 Etc/GMT+8' do
> puts "hello"
> end
> scheduler.join
>
> I cannot find the output in the screen.So does it output into a file?
> Or anything wrong with the code ?

Hello Dongcan,

how are you running the code? In IRB?

Try putting your code in a file an run it:

ruby dongcan.rb

Then wait for the "hello" to appear.


> I also want to know whether the "scheduler.join" is necessary in the
> cron job?

The scheduler.join is simply telling the Ruby runtime to join the scheduler
thread so that it doesn't exit immediately.

try running this program:

---8<---
Thread.new do
sleep 1.0
puts "hello"
end
--->8---

then this one:

---8<---
t = Thread.new do
sleep 1.0
puts "hello"
end
t.join
--->8---

See the difference.


> And this cronjob can be seen in the crontab?

No, it cannot. Rufus-scheduler will not touch your crontab, at all.

If you're looking for a Ruby integration with Cron, look at

https://github.com/javan/whenever


Best regards,

--
John Mettraux - http://lambda.io/processi

dongcan zhao

unread,
Apr 16, 2012, 9:29:33 PM4/16/12
to Rufus Ruby
Thank you . I also want to know whether the cronJob can be used in
Windows OS?

John Mettraux

unread,
Apr 16, 2012, 9:33:00 PM4/16/12
to rufus...@googlegroups.com

On Mon, Apr 16, 2012 at 06:29:33PM -0700, dongcan zhao wrote:
> Thank you . I also want to know whether the cronJob can be used in
> Windows OS?

Hello,

yes, rufus-scheduler can be used on Windows. I haven't tried for a long while
though.

Reply all
Reply to author
Forward
0 new messages