Question

I tried this :

0 0 */15 * * /usr/bin/mongo stories  /usr/share/cronjobs/15days.js
* * * * * touch /usr/share/neargood/testing.txt 

The testing.txt file is effectively created each minute, but the mongo script doesn't have any effect. 15days.js :

d=new Date();
mdate15 = new Date(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()-15);
db.story.update({ date: {$lte:mdate15} , active:1},{ $set: {active:0}},{ multi: true })

What could the problem be ?

Was it helpful?

Solution

What happens when you run the command by hand? Does it work? If so, it could be a permissions issue. Check all files involved to make sure that the cron user has privilege to read and/or execute where applicable.

If it runs manually, then I'd guess it's got something to do with how things are chmod'd and/or chown'd. Find out what user cron runs as, and check to see if the mongo binary can be run by it. Also, check the permissions and ownership of 15days.js

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top