• Cron job does not start

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #21497  by openkm@sitc.nl
 
Hi there,

I'm using version 6.2.1 build 7659 on OpenSuse 12.1.

For some reason my cron jobs do not start, they do run when I press the flash image but they won't start at the scheduled time see settings below:

FileBackup 05 * * * * application/x-bsh TopLevelFileBackup.bsh mymail@myprovider.nl

Do you any of you have an idea where the cause of this problem could lay, I searched the internet and did not find similar problems.

Thanks in advance
Harry
Last edited by openkm@sitc.nl on Wed Feb 27, 2013 12:49 pm, edited 1 time in total.
 #21528  by openkm@sitc.nl
 
I don quite get what you mean, I tested the script by pressing the flash icon in the cron view. The script was executed succesful so it appears to be correct. Just to be sure I placed a very simple script in a second cron entry which also was not executed.

It seems that due to some installation/config error the crontab is not triggered but I can't find out what is it, there's no warning or error related to that in the logs either.
 #21551  by jllort
 
sincerally there's no mistery, if you declare correctly will be executed correctly ( you can force execution from administration with flash icon ), sure you tested in scripting view ? if you want can share here and we will take a look on it.
 #21556  by openkm@sitc.nl
 
Here's the script I'm using:
Code: Select all
import com.openkm.core.*;
import com.openkm.util.impexp.*;
import com.openkm.module.db.stuff.DbSessionManager;
import com.openkm.util.FileUtils;


StringWriter out = new StringWriter();

RepositoryExporter.exportDocuments(null, "/okm:root/", new File("/home/sugarcrm/docbackup/"), false, false, out, new TextInfoDecorator("/okm:root/"));

print("All documents copied");
BTW: Scripting view shows proper results, I'm pretty sure it's just cron not starting the script but don't know where to look for that problem.
 #21585  by jllort
 
Whne you export from crontab you need a token not null because you should not be logged at the moment crontab is executing. You should use systemToken like
Code: Select all
String systemToken = DbSessionManager.getInstance().getSystemToken();
 #21607  by openkm@sitc.nl
 
So I changed the script to:
Code: Select all
import com.openkm.core.*;
import com.openkm.util.impexp.*;
import com.openkm.module.db.stuff.DbSessionManager;
import com.openkm.util.FileUtils;

String systemToken = DbSessionManager.getInstance().getSystemToken();
StringWriter out = new StringWriter();
RepositoryExporter.exportDocuments(systemToken, "/okm:root/", new File("/home/sugarcrm/docbackup/"), false, false, out, new TextInfoDecorator("/okm:root/"));

print("All documents copied");
Now pressing the flash sign results in receiving an email:
Code: Select all
Sourced file: inline evaluation of: ``import com.openkm.core.*; import com.openkm.util.impexp.*; import com.openkm.m . . . '' : Method Invocation RepositoryExporter.exportDocuments : at Line: 11 : in file: inline evaluation of: ``import com.openkm.core.*; import com.openkm.util.impexp.*; import com.openkm.m . . . '' : RepositoryExporter .exportDocuments ( systemToken , "/okm:root/" , new File ( "/home/sugarcrm/docbackup/" ) , false , false , out , new TextInfoDecorator ( "/okm:root/" ) ) Target exception: java.lang.NullPointerException
Which means that an script that contains some kind of error will result in an email. Note that it is still not executed automatically which is my real problem here.

I'm still pretty convinced that the cron task is simply not started automatically else I would receive an email containing the error. Right or not?

Is there a simple check to see if cron works normally?

Regards,
Harry
 #21621  by jllort
 
Several observations:
1- I suggest change "/okm:root/" to "/okm:root" ( without / at ends
2- Ensure user who's executing openkm ( which is running tomcat ) has grants to write under the folder /home/sugarcrm/docbackup/ ( I think this could be the reason of get null -> you can try print file object to be sure about it);
 #21626  by openkm@sitc.nl
 
Ok, let's not focus on the script because if it contains an error it still would be executed to the point where it crashes and the results would be shown in the email.

To test the cron execution I followed the wiki again and implemented the example (http://wiki.openkm.com/index.php/Crontab).

I added the BeanShell sample with a bash script, note that the example on the wiki contains an error:
Code: Select all
for (int i=0; i<5; i++) {
  print("Iteration: " + i + "<br/>);
}
In the print statement the closing quote is missing. Adding this script with error in the following cron setup did nothing:

TEST 45 * * * * application/x-bsh TESTCRON.bsh mymail@mydomain

I would expect an email at 45 minutes past each hour with the scripting error which I did not get.
Pressing the flash sign does result in an email so it appears to me that the settings are correct otherwise OpenKM would not be able to send the mail.

So far nothing new as I stated from the beginning that I supect cron from just not being triggered but:

Once I've corrected the error, so now the code looks like:
Code: Select all
for (int i=0; i<5; i++) {
  print("Iteration: " + i + "<br/>");
}
It does nothing automatically so same behavior as before and if I start it with the flash sign it does NOT send an email. So the email is only send in case an error occurs and not if output is generated, this is weird.

So please focus on the cron mechanism as I now showed that it can't be the script.

Thanks in advance,
Harry
 #21638  by jllort
 
I suggest upgrade to lastest openkm version 6.2.2 i do not know if version 6.2.1 have some problem on it ( is strange ). To test in deep use a crontab wih 1-2 minutes not 45. In mail put your mail address if there's some error should be sent a mail to your account.

If not goes right after update, place here the script and I will test in on my community environment.
 #22708  by openkm@sitc.nl
 
Dear responders,
Just upgraded to 6.2.3 which solved the cron issue, My script results in an error but that's a different story ;-).

Thanks for you support, consider this problem to be solved.

Cheers,
Harry

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.