It is always a struggle configuring a cronjob to run certain scripts; there is always a mis configuration, a PATH, an environment variable that is different from when you use it in interactive mode, etc… Do you have any tricks to avoid or minimize those issues?

cc @selfhost@lemmy.ml

  • skilltheamps@feddit.de
    link
    fedilink
    arrow-up
    9
    ·
    1 year ago

    Use a systemd-service + systemd-timer. You can then run “systemctl start myjob.service” to check that it runs as you expect. If it works “systemctl enable --now myjob.timer” to kick it off as scheduled

  • nitrolife@rekabu.ru
    link
    fedilink
    arrow-up
    6
    ·
    1 year ago

    You can use crontab -e from user. That set user environment to usual state. Or you can use systems timers instead crontab.

    Or you can set all environment variables inside cron file.

  • johntash@eviltoast.org
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Depending on what your setup is like, you could use something other than cron.

    Kubernetes and Nomad both have cron-like schedulers. It’s convenient to keep your cronjob definitions near the app code.

    I’ve also been using windmill.dev lately for some simple cronjob-like tasks and it’s working pretty great. It also has a UI if that helps.

  • Kimusan@feddit.dk
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    If Cron is too hard for you (it is really easy so I don’t really understand your problems) then check out runat instead. Simple and easy to use with all the features I would suspect you use in cron