Hi team,
I don't have the same execution if i launch my crontask with the "Execute" button or if I am waiting the cron is launch automatically.
The script create an export of my repository and he zip him.
It works properly if i click on Execute...
See the code :
here is the configuration of my cronJob, i think is it configure properly because i test every time with adapted settings "Expression":
thank you in advance for your help
I don't have the same execution if i launch my crontask with the "Execute" button or if I am waiting the cron is launch automatically.
The script create an export of my repository and he zip him.
It works properly if i click on Execute...
See the code :
Code: Select all
See the log who appear when the cron job is execute :
import java.io.File;
import java.io.FileOutputStream;
import java.io.StringWriter;
import com.openkm.util.FileUtils;
import com.openkm.util.impexp.RepositoryExporter;
import com.openkm.util.impexp.TextInfoDecorator;
import com.openkm.util.ArchiveUtils;
import org.apache.commons.io.IOUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
//test de nouvelles classes
import com.openkm.api.*;
import com.openkm.core.*;
//formatage de la variable DOM
DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd");
Calendar cal = Calendar.getInstance();
String DOM = dateFormat.format(cal.getTime());
// Destination
File file = new File("/home/BACKUP/OpenKM/"+DOM+"_RepositoryExport.zip");
// OpenKM folder contents to be exported
String fldPath = "/okm:root";
FileOutputStream os = new FileOutputStream(file);
StringWriter out = new StringWriter();
File tmp = FileUtils.createTempDir();
RepositoryExporter.exportDocuments(null, fldPath, tmp, false, false, out, new TextInfoDecorator(fldPath));
ArchiveUtils.createZip(tmp, "import", os);
org.apache.commons.io.FileUtils.deleteDirectory(tmp);
IOUtils.closeQuietly(out);
os.flush();
os.close();
Code: Select all
2016-10-26 11:59:00,143 [Thread-6516] INFO com.openkm.module.db.stuff.DbSimpleAccessManager- ***************************
2016-10-26 11:59:00,143 [Thread-6516] INFO com.openkm.module.db.stuff.DbSimpleAccessManager- ***************************
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.module.db.stuff.DbSimpleAccessManager -> isGranted (DbSimpleAccessManager.java:68)
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.module.db.stuff.SecurityHelper -> checkRead (SecurityHelper.java:96)
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.dao.NodeMailDAO -> findByParent (NodeMailDAO.java:130)
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.module.db.DbMailModule -> getChildren (DbMailModule.java:530)
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.util.impexp.RepositoryExporter -> exportDocumentsHelper (RepositoryExporter.java:153)
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.util.impexp.RepositoryExporter -> exportDocuments (RepositoryExporter.java:70)
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.util.ExecutionUtils -> runScript (ExecutionUtils.java:112)
2016-10-26 11:59:00,143 [Thread-6516] WARN com.openkm.module.db.stuff.DbSimpleAccessManager- com.openkm.core.Cron$RunnerBsh -> run (Cron.java:103)
2016-10-26 11:59:00,143 [Thread-6516] INFO com.openkm.module.db.stuff.DbSimpleAccessManager- ***************************
2016-10-26 11:59:00,143 [Thread-6516] INFO com.openkm.module.db.stuff.DbSimpleAccessManager- ***************************
2016-10-26 11:59:00,144 [Thread-6516] WARN com.openkm.core.Cron- Error executing crontab task 'Backup_repository': bsh.TargetError: Sourced file: inline evaluation of: ``import java.io.File; import java.io.FileOutputStream; import java.io.StringWrite . . . '' : Method Invocation RepositoryExporter.exportDocuments : at Line: 29 : in file: inline evaluation of: ``import java.io.File; import java.io.FileOutputStream; import java.io.StringWrite . . . '' : RepositoryExporter .exportDocuments ( null , fldPath , tmp , false , false , out , new TextInfoDecorator ( fldPath ) )
Target exception: java.lang.NullPointerException
2016-10-26 11:59:00,148 [Thread-6516] WARN com.openkm.core.Cron- Error sending mail: Sourced file: inline evaluation of: ``import java.io.File; import java.io.FileOutputStream; import java.io.StringWrite . . . '' : Method Invocation RepositoryExporter.exportDocuments : at Line: 29 : in file: inline evaluation of: ``import java.io.File; import java.io.FileOutputStream; import java.io.StringWrite . . . '' : RepositoryExporter .exportDocuments ( null , fldPath , tmp , false , false , out , new TextInfoDecorator ( fldPath ) )
Target exception: java.lang.NullPointerException
here is the configuration of my cronJob, i think is it configure properly because i test every time with adapted settings "Expression":
Code: Select all
Backup_repository 59 11 * * * application/x-bsh Backup_OpenKM.bsh noreply@openkm.com 26-10-2016 11:52:00 26-10-2016 11:52:00 Active Edit Delete Execute Downloadthank you in advance for your help
