Hi Paul, if your command uses some session resources (like stream), it's normal as the session is closed when you quit the shell.
For mail reporting, it's better to create a service that you trigger with a command (one shot) or with the scheduled (trigger/cron). Regards JB On Mon, May 16, 2022 at 7:20 PM Paul Spencer <[email protected]> wrote: > > Karaf 4.3.6 > > I have scheduled a command to run on a cron schedule, but the command fails > with "java.lang.IllegalStateException: session is closed" after I exit the > Karaf client session. The command will only run in the client session > scheduling the command. > > Since command execution can be schedule, I would expect the client session > scheduling the command would not be required for each execution. > > What is I doing wrong? > > > *** > * Command to schedule the execution of foo:emailReport at 5PM > ** > karaf@root()> scheduler:schedule-command --cron "0 0 17 * * ?" > "foo:emailReport -r [email protected] &" > karaf@root()> scheduler:list > Name │ Schedule > ──────────────────────────────────────────┼─────────────────────────────────────────── > foo:emailReport -r [email protected] │ cron(0 0 17 * * ?) > > *** > * karaf.log > *** > 2022-05-15T17:00:00,025 | WARN | Karaf_Worker-5 | ScriptJob > | 80 - org.apache.karaf.scheduler.core - 4.3.6 | Error executing > scheduled command foo:emailReport -r [email protected] & > java.lang.IllegalStateException: session is closed > at > org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:171) > ~[?:?] > at > org.apache.karaf.shell.impl.console.ConsoleSessionImpl.execute(ConsoleSessionImpl.java:496) > ~[?:?] > at > org.apache.karaf.scheduler.command.support.CommandJob.execute(CommandJob.java:40) > [!/:?] > at > org.apache.karaf.scheduler.core.QuartzJobExecutor.execute(QuartzJobExecutor.java:58) > [!/:?] > at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [!/:?] > at > org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) > [!/:?] > 2022-05-15T17:03:41,930 | INFO | Karaf_Worker-6 | > ServiceRequestEmailReceiver | 152 - > com.alexanderpest.bugdata.msg-email-receiver - 2.0.2 | Message count = 554 > > > karaf@root()> scheduler:list > Name │ Schedule > ──────────────────────────────────────────┼─────────────────────────────────────────── > foo:emailReport -r [email protected] & │ cron(0 0 17 * * ?) > > > Paul Spencer
