Help in definining new cronjobs in OTRS 5

Moderator: crythias

Locked
Treuz
Znuny newbie
Posts: 10
Joined: 23 Jun 2014, 13:13
Znuny Version: 5.0.2

Help in definining new cronjobs in OTRS 5

Post by Treuz »

Hello,

i've upgraded from OTRS 4 to 5 and i need some help for "translating" the old cronjobs in the new platform.

Prior to version 5 i used an embedded Perl script with all the options defined in the cron commad:

Code: Select all

/opt/otrs/bin/otrs.GenerateStats.pl -n 10013 -f Print -s "OTRS Service <sender@mycompany.com>" -r me@mycompany.com -m "Mail Body" >/dev/null
But now cronjobs are managed by OTRS Daemon and the corresponding command is changed as follows:

Code: Select all

/opt/otrs/bin/otrs.Console.pl Maint::Stats::Generate --number 10013 --format Print --mail-sender 'OTRS Service <sender@mycompany.com>' --mail-recipient me@mycompany.com --mail-body 'Mail Body'
If i launch this command from prompt i have no problem, and the report is successfully sent. By the way I'm having problem in configuring the corresponding command in the GUI, i tried with the options below:
ScreenShot200.png
But i guess that the command is malformed since i got some errors in otrs.log:

Code: Select all

[Tue Nov 24 09:10:13 2015][Error][Kernel::System::Daemon::DaemonModules::BaseTaskWorker::_HandleError][51] There was an error executing Execute() in Kernel::System::Console::Command::Maint::Stats::Generate: Error: please provide option '--number'.

Generate (and send, optional) statistics which have been configured previously in the OTRS statistics module.

Usage:
 otrs.Console.pl Maint::Stats::Generate --number ... [--params ...] [--target-filename ...] [--target-directory ...] [--format ...] [--separator ...] [--with-header] [--timezone ...] [--language ...] [--mail-sender ...] [--mail-recipient ...(+)] [--mail-body ...]

Options:
 --number ...                   - Statistic number as shown in the overview of AgentStats.
 [--params ...]                 - Parameters which should be passed to the statistic (e.g. Year=1977&Month=10, not for dynamic statistics).
 [--target-filename ...]        - Filename for the generated file.
 [--target-directory ...]       - Directory to which the generated file should be written (e.g. /output/dir/). If a target directory is provided, no email will be sent.
 [--format ...]                 - Target format (CSV|Excel|Print) for which the file should be generated (defaults to CSV).
 [--separator ...]              - Defines the separator in case of CSV as target format (defaults to ';').
 [--with-header]                - Adds a heading line consisting of statistics title and creation date in case of Excel or CSV as output format.
 [--timezone ...]               - Target time zone (e.g. +2) for which the file should be generated (only provided, if the system use UTC as system time, the TimeZoneUser feature is active and for dynamic statistics).
 [--language ...]               - Target language (e.g. de) for which the file should be generated (will be OTRS default language or english as fallback if left empty).
 [--mail-sender ...]            - Email address which should appear as sender for the generated file.
 [--mail-recipient ...(+)]      - Recipient email address to which the generated file should be send.
 [--mail-body ...]              - Body content for the email which has the generated statistics file attached.
 [--help]                       - Display help for this command.
 [--no-ansi]                    - Do not perform ANSI terminal output coloring.
 [--allow-root]                 - Allow root user to execute the command.

I really don't know how to write my command in the GUI, can anybody point me in the right direction?

Thanks in advance,
Treuz
You do not have the required permissions to view the files attached to this post.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Help in definining new cronjobs in OTRS 5

Post by crythias »

http://otrs.github.io/doc/manual/admin/ ... aemon.html
It appears to be that you send the key/param then the value.
Last edited by crythias on 24 Nov 2015, 16:21, edited 1 time in total.
Reason: updated link
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Treuz
Znuny newbie
Posts: 10
Joined: 23 Jun 2014, 13:13
Znuny Version: 5.0.2

Re: Help in definining new cronjobs in OTRS 5

Post by Treuz »

Thank you for your answer but the link isn't working.

I don't understand what you mean: i don't know exactly what "Param" means. I wrongly supposed that was an equivalent for "options", since normally i need to specify options for the command instead of Parameters. Could you please be more specific?

Don't know if this can help but I have the following in my ZZZAuto.pm:

Code: Select all

$Self->{'Daemon::SchedulerCronTaskManager::Task'}->{'Custom1'} =  {
  'Function' => 'Execute',
  'MaximumParallelInstances' => '1',
  'Module' => 'Maint::Stats::Generate',
  'Params' => [
    '--number',
    '10012',
    '--format',
    'print',
    '--mail-sender',
    '\'OTRS Service <sender@mycompany.com>\'',
    '--mail-recipient',
    'me@mycompany.com',
    '--mail-body',
    '\'Mail Body\''
  ],
  'Schedule' => '10 09 * * 1-5',
  'TaskName' => 'Custom1'
};
I just need to understand how i can specify options like --mail-sender or --mail-body

Thank you,
Treuz
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Help in definining new cronjobs in OTRS 5

Post by crythias »

unfortunately, I think you might guess the "answer" being one param per space delimited word.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Treuz
Znuny newbie
Posts: 10
Joined: 23 Jun 2014, 13:13
Znuny Version: 5.0.2

Re: Help in definining new cronjobs in OTRS 5

Post by Treuz »

I'm sorry crythias but your answers are confusing me.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Help in definining new cronjobs in OTRS 5

Post by crythias »

Code: Select all

'"one',
'entry',
'per',
'space',
'delimited',
'word."'
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Treuz
Znuny newbie
Posts: 10
Joined: 23 Jun 2014, 13:13
Znuny Version: 5.0.2

Re: Help in definining new cronjobs in OTRS 5

Post by Treuz »

Thank you crythias, i finally managed to get it work.

My syntax was correct: one entry per row.

The error was about the --format options that need Print with capital "P".
Locked