GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
App::RunCron(3) User Contributed Perl Documentation App::RunCron(3)

App::RunCron - making wrapper script for crontab

    use App::RunCron;
    my $runner = App::RunCron->new(
        timestamp => 1,
        command   => [@ARGV],
        logfile   => 'tmp/log%Y-%m-%d.log',
        reporter  => 'Stdout',
        error_reporter => [
            'Stdout',
            'File', {
                file => 'tmp/error%Y-%m-%d.log'
            },
        ],
    );
    $runner->run;

App::RunCron is a software for making wrapper script for running cron tasks.

App::RunCron can separate reporting way if the command execution success or failed (i.e. fails to start, or returns a non-zero exit code, or killed by a signal). It is handled by `reporter` and `error_reporter` option.

By default, `reporter` is 'None' and `error_reporter` is 'Stdout'. It prints the outputs the command if and only if the command execution failed. In other words, this behaviour causes cron(8) to send mail when and only when an error occurs.

Default behaviour is same like cronlog <https://github.com/kazuho/kaztools/blob/master/cronlog>.

Add timestamp or not. (Default: undef)

Identifier of the job name. (Optional)

command to be executed. (Required)

If logfile is specified, stdout and stderr of the command will be logged to the file so that it could be used for later inspection. If not specified, the outputs will not be logged. The logfile can be a "strftime" format. eg. '%Y-%m-%d.log'. (NOTICE: '%' must be escaped in crontab.)

"common_reporter" is optional, processing after "(error_)?reporter" is handled.

The "reporter", "error_reporter" and "common_reporter" can be like following.

$module_name
"[$module_name[, \%opt], ...]"
$coderef

$module_name package name of the plugin. You can write it as two form like Plack::Middleware:

    reporter => 'Stdout',    # => loads App::RunCron::Reporter::Stdout

If you want to load a plugin in your own name space, use the '+' character before a package name, like following:

    reporter => '+MyApp::Reporter::Foo', # => loads MyApp::Reporter::Foo

Package name of an "Announcer" which announce job information before running the job. (Optional)

"$self->run"

Running the job.

"my $str = $self->result_line"

One line result string of the command.

"my $str = $self->report"

Retrieve the output of the command.

"my $bool = $self->is_success"

command is success or not.

"my $int = $self->exit_code"

same as $?

"my $int = $self->child_exit_code"

exit code of child process.

"my $int = $self->child_signal"

signal number if chile process accepted a signal.

runcron, cronlog <https://github.com/kazuho/kaztools/blob/master/cronlog>

Copyright (C) Songmu.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Songmu <y.songmu@gmail.com>
2022-04-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.