How do I automatically run a php script every minute?

I have installed the learning management system called moodle to my system. Mostly it is working, however there is a php script called “cron.php” that should run once per minute.

I am confused on how to implement running this every minute. Id’ like to do it the most “arch/manjaro” way - so I assume that means via systemd somehow? Most of the moodle instructions I’ve seen imply or assume using cron (cronie?) and crontab.

from the command line I can invoke as: sudo php /srv/http/moodle/admin/cli/cron.php and it does it’s magic just fine. What I don’t understand at all is how to invoke this on a regular time schedule, namely every minute.

Based on what I’ve read, I’m not sure it I should be trying to invoke this via crontab -e, or directly writing into one of the several cron-related directories (and if so, which?) or should I be trying invoke this via some systemd “timer” and “service” - not that I really know what those terms mean!

Any and all suggestions appreciated!

For systemd, create a moodle.service that runs your script, no need for any install because:

Then create moodle.timer and configure to start once per minute (or whatever time you want)

See systemd/Timers - ArchWiki


I would use systemd timers as @bedna stated.