CLI cron tasks on AWS Lambda

AWS Lambda lets us run console commands as cron tasks using the schedule event:

        handler: bin/console # or 'artisan' for Laravel
        runtime: php-81-console
            - schedule:
                  rate: rate(1 hour)
                  input: '"list --verbose"'

The example above will run the bin/console list --verbose command every hour in AWS Lambda.

Note that the command is a double quoted string: '"command"'. Why? The input value needs to be valid JSON, which means that it needs to be a JSON string, stored in a YAML string.

Read more about the schedule feature in the Serverless documentation.

If you are interested in cron functions instead, read the Cron functions documentation.