How to Create a Cron Job (Scheduled Task) on server

1,492 views
Skip to first unread message

玉 付

unread,
Mar 24, 2011, 7:37:04 AM3/24/11
to mongodb-user
We need to remove expired documents , or do mapReduce in 0:0:0 everyday

Nat

unread,
Mar 24, 2011, 7:39:48 AM3/24/11
to mongodb-user
For your use case, you might want to watch for this enhancement
http://jira.mongodb.org/browse/SERVER-211. For now, you need to
probably run cron job to execute db.remove() to remove documents you
don't need anymore.

Scott Hernandez

unread,
Mar 24, 2011, 7:43:24 AM3/24/11
to mongod...@googlegroups.com
This really has very little to do with mongodb; most operating systems
have a way to run scheduled programs (cron/windows task
scheduler/etc).

You can choose your operating systems favorite tool and your favorite
language to write those scripts.

Another option for expiring documents is to use a capped collection
and always ignore old docs by using a query with a time based filter.
Soon a TTL option will be added.

On Thu, Mar 24, 2011 at 7:37 AM, 玉 付 <freese...@gmail.com> wrote:
> We need to remove expired documents , or do mapReduce in 0:0:0 everyday
>

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

玉 付

unread,
Mar 24, 2011, 8:39:22 AM3/24/11
to mongodb-user
Yes,I agree with you.
But ,see http://groups.google.com/group/mongodb-user/browse_thread/thread/ba76644314ce1cfc
I cannot run scheduled job in java application, so want to run it on
mongodb server.

Just found that I could scripte the shell , "./mongo localhost:27015/
test test.js"

@Nat,TTL based capped collection is also great , I 've watched the
issue.

Thanks very much

Scott Hernandez

unread,
Mar 24, 2011, 8:44:00 AM3/24/11
to mongod...@googlegroups.com
The problem you are having in java can be resolved, I'm pretty sure;
if that is all this keeping you from using that for your scheduled
task then it is surmountable. I would suggest using technology you are
familiar with, and is part your core competency.


2011/3/24 玉 付 <freese...@gmail.com>:


> Yes,I agree with you.
> But ,see http://groups.google.com/group/mongodb-user/browse_thread/thread/ba76644314ce1cfc
> I cannot run scheduled job in java application, so want to run it on
> mongodb server.
>
> Just found that I could scripte the shell ,  "./mongo localhost:27015/
> test test.js"

Yep, that is an option as well.

Reply all
Reply to author
Forward
0 new messages