ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    LVM Snapshot script

    Scheduled Pinned Locked Moved IT Discussion
    lvmsnapshotsbash
    3 Posts 2 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplatesS
      stacksofplates
      last edited by

      So I noticed an issue, I figured I'd post it in case anyone else has the same problem.

      I created a bash script on a CentOS 7 server to do some LVM snapshots and then export them to .gzip files. If I put the script under /etc/cron.daily it worked fine, however if I added the script in crontab as root or sudo, the script would run, but would give the error command not found for lvcreate and lvremove.

      I just had to add this to the script:

      PATH=/usr/sbin:/usr/bin:/sbin:/bin
      

      and it works fine now.

      1 Reply Last reply Reply Quote 1
      • scottalanmillerS
        scottalanmiller
        last edited by

        Best practice, which almost no one follows, is to use explicit paths in scripts rather than implicit. then you don't need that at all.

        stacksofplatesS 1 Reply Last reply Reply Quote 1
        • stacksofplatesS
          stacksofplates @scottalanmiller
          last edited by

          @scottalanmiller said:

          Best practice, which almost no one follows, is to use explicit paths in scripts rather than implicit. then you don't need that at all.

          I guess that makes 100% sense since you have to start the script with an absolute path ha.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post