All Recipes

Cron

Base Provider

None

Author @aleks

This template allows you to run cron jobs with the Schedule::Cron Perl package. mcron can also be used, but Schedule::Cron leads to a faster build and a smaller result image.

railpack.json

{
  "deploy": {
    "aptPackages": ["perl", "libschedule-cron-perl"]
  }
}

start.sh

#!/usr/bin/env bash

chmod +x /app/*.bash
echo starting cron
perl run.pl

crontab

*/15 * * * * /app/myscript.bash

run.pl

use v5.10;
use Schedule::Cron;

sub dispatcher {
    system(@_[0]);
}

my $cron = new Schedule::Cron(\&dispatcher);
$cron->load_crontab("/app/crontab");
$cron->run(detach=>0);

myscript.bash

#!/usr/bin/env bash
echo Hello World!