Hello everyone!

I’m running a few different services off of my Ubuntu VM on ProxMox, and they’ve all been running great for about 6 months now. However, I’m trying to setup some better backups and such of individual services, and I wrote a bash script to do that for me and delete older backups once I accumulate enough.

All of that works 100% fine. Like absolutely no issues with the script when I run it myself. However, I can not for the life of me get crontab to run it.

If I run sudo ./folder/directory/backup.sh then everything runs perfectly. However, if I setup my crontab with 0 * * * * ./folder/directory/backup.sh I get absolutely nothing.

I have also tried setting the crontab with sudo, sh, sudo sh, and both combinations without the dot in front of the path to the shell script.

Does anyone have any idea what I am doing wrong?

Thank you so much for any help

Update: I have edited /etc/crontab with the following 0 * * * * * root /mnt/nas/freshrss/backups/backup.sh. After waiting for the crontab to fire off, nothing happened. Still not really sure what’s going on.

  • foo@withachanceof.com
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago
    0 * * * * * root /mnt/nas/freshrss/backups/backup.sh
    

    Why do you have root in there? If you need something to run as root do sudo crontab -e and edit the root user’s crontab accordingly. The user shouldn’t be specified in the crontab directly.

    • theRealBassist@lemmy.worldOP
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      The crontab that is found at /etc/crontab very specifically states that it has a user field. I will readily admit that I might be misunderstanding it, but that feels pretty explicit to me.

      • foo@withachanceof.com
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        1 year ago

        What distro are you using? I haven’t seen /etc/crontab in quite a while with the advent of the /etc/cron.d directory. That said, crontab -e will handle this stuff for you.

        Edit: I see, Ubuntu. I’m not too familiar with what they’re doing over there. I have an /etc/cron.d dir on my Arch boxes. Some other stuff to check though: does any cron job run? If not, is the service running? You could also redirect this script’s output to a file under /tmp or something to check if it’s running and what might be going wrong. Beyond that, check the systemd logs for any errors.